AST: Clean up getMemberSubstitutions() and friends

Rename the old getMemberSubstitutions() to getContextSubstitutions()
and add a new getMemberSubstitutions() that takes a ValueDecl, rather
than the member's DeclContext.

This new method forwards generic parameters if the member is a generic
function.
This commit is contained in:
Slava Pestov
2016-12-15 22:42:09 -08:00
parent ba81349542
commit 3989aea9ae
10 changed files with 62 additions and 37 deletions

View File

@@ -1985,15 +1985,14 @@ public:
MaybeNominalType->getAnyOptionalObjectType())
MaybeNominalType = MaybeNominalType->getAnyOptionalObjectType();
// For dynamic lookup don't substitute in the base type
// For dynamic lookup don't substitute in the base type.
if (MaybeNominalType->isAnyObject())
return T;
// For everything else, substitute in the base type.
//
// Pass in DesugarMemberTypes so that we see the actual
// concrete type witnesses instead of type alias types.
auto Subs = MaybeNominalType->getMemberSubstitutions(
auto Subs = MaybeNominalType->getContextSubstitutions(
VD->getDeclContext());
T = T.subst(M, Subs, (SubstFlags::DesugarMemberTypes |
SubstFlags::UseErrorType));