Takes a T valid in the context of a trait ref and transforms it into a T valid in the
context of its vtable definition, i.e. no longer mentions the Self type or Self clause. If
new_self is Some, we replace any mention of the Self type with it; otherwise we panic if
Self is mentioned.
If for_method is true, weโre handling a value coming from a AssocFn, which takes the Self
clause as its first clause parameter. Otherwise weโre in trait scope, where the Self clause
is represented with TraitRefKind::SelfId.