AST: Get rid of old form of Type::subst()

First, add some new utility methods to create SubstitutionMaps:

- GenericSignature::getSubstitutionMap() -- provides a new
  way to directly build a SubstitutionMap. It takes a
  TypeSubstitutionFn and LookupConformanceFn. This is
  equivalent to first calling getSubstitutions() with the two
  functions to create an ArrayRef<Substitution>, followed by
  the old form of getSubstitutionMap() on the result.

- TypeBase::getContextSubstitutionMap() -- replacement for
  getContextSubstitutions(), returning a SubstitutionMap.

- TypeBase::getMemberSubstitutionMap() -- replacement for
  getMemberSubstitutions(), returning a SubstitutionMap.

With these in place, almost all existing uses of subst() taking
a ModuleDecl can now use the new form taking a SubstitutionMap
instead. The few remaining cases are explicitly written to use a
TypeSubstitutionFn and LookupConformanceFn.
This commit is contained in:
Slava Pestov
2017-02-01 23:48:30 -08:00
parent 5a9f674bf8
commit cf4043b668
18 changed files with 181 additions and 100 deletions

View File

@@ -2003,12 +2003,13 @@ public:
return T;
// For everything else, substitute in the base type.
auto Subs = MaybeNominalType->getMemberSubstitutions(VD);
auto Subs = MaybeNominalType->getMemberSubstitutionMap(M, VD);
// Pass in DesugarMemberTypes so that we see the actual
// concrete type witnesses instead of type alias types.
T = T.subst(M, Subs, (SubstFlags::DesugarMemberTypes |
SubstFlags::UseErrorType));
T = T.subst(Subs,
(SubstFlags::DesugarMemberTypes |
SubstFlags::UseErrorType));
}
}