@@ -1961,8 +1961,11 @@ class SubstFunctionTypePatternVisitor
1961
1961
: CanType (CanMetatypeType::get (substInstance));
1962
1962
}
1963
1963
1964
- CanType handleGenericNominalType (CanType orig, CanType subst,
1965
- CanGenericSignature origSig) {
1964
+ CanType handleGenericNominalType (AbstractionPattern origPattern, CanType subst) {
1965
+ CanType orig = origPattern.getType ();
1966
+ CanGenericSignature origSig = origPattern.getGenericSignatureOrNull ();
1967
+ auto origPatternSubs = origPattern.getGenericSubstitutions ();
1968
+
1966
1969
// If there are no loose type parameters in the pattern here, we don't need
1967
1970
// to do a recursive visit at all.
1968
1971
if (!orig->hasTypeParameter ()
@@ -2007,6 +2010,7 @@ class SubstFunctionTypePatternVisitor
2007
2010
if (differentOrigClass) {
2008
2011
orig = subst;
2009
2012
origSig = TC.getCurGenericSignature ();
2013
+ origPatternSubs = SubstitutionMap ();
2010
2014
assert ((!subst->hasTypeParameter () || origSig) &&
2011
2015
" lowering mismatched interface types in a context without "
2012
2016
" a generic signature" );
@@ -2028,7 +2032,8 @@ class SubstFunctionTypePatternVisitor
2028
2032
->getCanonicalType ();
2029
2033
2030
2034
replacementTypes[gp->getCanonicalType ()->castTo <SubstitutableType>()]
2031
- = visit (substParamTy, AbstractionPattern (origSig, origParamTy));
2035
+ = visit (substParamTy,
2036
+ AbstractionPattern (origPatternSubs, origSig, origParamTy));
2032
2037
}
2033
2038
2034
2039
auto newSubMap = SubstitutionMap::get (nomGenericSig,
@@ -2048,8 +2053,7 @@ class SubstFunctionTypePatternVisitor
2048
2053
// If the type is generic (because it's a nested type in a generic context),
2049
2054
// process the generic type bindings.
2050
2055
if (!isa<ProtocolDecl>(nomDecl) && nomDecl->isGenericContext ()) {
2051
- return handleGenericNominalType (pattern.getType (), nom,
2052
- pattern.getGenericSignatureOrNull ());
2056
+ return handleGenericNominalType (pattern, nom);
2053
2057
}
2054
2058
2055
2059
// Otherwise, there are no structural type parameters to visit.
@@ -2058,8 +2062,7 @@ class SubstFunctionTypePatternVisitor
2058
2062
2059
2063
CanType visitBoundGenericType (CanBoundGenericType bgt,
2060
2064
AbstractionPattern pattern) {
2061
- return handleGenericNominalType (pattern.getType (), bgt,
2062
- pattern.getGenericSignatureOrNull ());
2065
+ return handleGenericNominalType (pattern, bgt);
2063
2066
}
2064
2067
2065
2068
CanType visitPackType (CanPackType pack, AbstractionPattern pattern) {
@@ -2085,7 +2088,7 @@ class SubstFunctionTypePatternVisitor
2085
2088
// the pack substitution for that parameter recorded in the pattern.
2086
2089
2087
2090
// Remember that we're within an expansion.
2088
- // FIXME: when we introduce PackReferenceType we'll need to be clear
2091
+ // FIXME: when we introduce PackElementType we'll need to be clear
2089
2092
// about which pack expansions to treat this way.
2090
2093
llvm::SaveAndRestore<bool > scope (WithinExpansion, true );
2091
2094
0 commit comments