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

@@ -387,8 +387,8 @@ public:
/// substitution according to the witness substitutions.
CanType getSubstWitnessInterfaceType(CanType type) {
auto subs = SubstSelfType->getRValueInstanceType()
->getMemberSubstitutions(WitnessStorage);
return type.subst(SGM.SwiftModule, subs)->getCanonicalType();
->getMemberSubstitutionMap(SGM.SwiftModule, WitnessStorage);
return type.subst(subs)->getCanonicalType();
}
};