mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Narrow TypeSubstitutionMap to SubstitutableType keys.
Type substitution works on a fairly narrow set of types: generic type parameters (to, e.g., use a generic) and archetypes (to map out of a generic context). Historically, it was also used with DependentMemberTypes, but recent refactoring to eliminate witness markers eliminate that code path. Therefore, narrow TypeSubstitutionMap's keys to SubstitutableType, which covers archetypes and generic type parameters. NFC
This commit is contained in:
@@ -595,7 +595,8 @@ TypeBase::gatherAllSubstitutions(Module *module,
|
||||
unsigned index = lastGenericIndex - boundGeneric->getGenericArgs().size();
|
||||
for (Type arg : boundGeneric->getGenericArgs()) {
|
||||
auto paramTy = genericParams[index++];
|
||||
substitutions[paramTy->getCanonicalType().getPointer()] = arg;
|
||||
substitutions[
|
||||
paramTy->getCanonicalType()->castTo<GenericTypeParamType>()] = arg;
|
||||
}
|
||||
lastGenericIndex -= boundGeneric->getGenericArgs().size();
|
||||
|
||||
@@ -618,8 +619,9 @@ TypeBase::gatherAllSubstitutions(Module *module,
|
||||
parentDC = parentDC->getParent();
|
||||
if (auto *outerEnv = parentDC->getGenericEnvironmentOfContext()) {
|
||||
for (auto gp : outerEnv->getGenericParams()) {
|
||||
auto result = substitutions.insert({gp->getCanonicalType().getPointer(),
|
||||
outerEnv->mapTypeIntoContext(gp)});
|
||||
auto result = substitutions.insert(
|
||||
{gp->getCanonicalType()->castTo<GenericTypeParamType>(),
|
||||
outerEnv->mapTypeIntoContext(gp)});
|
||||
assert(result.second);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user