Skip to content

Commit eeae6cf

Browse files
committed
SIL: Fix for when conditional requirements reference nested type parameters
1 parent 2feb76d commit eeae6cf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/AST/Type.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ class IsBindableVisitor
18501850
auto genericSig = decl->getGenericSignature();
18511851

18521852
SmallVector<Type, 4> newParams;
1853-
llvm::DenseMap<Type, Type> newParamsMap;
1853+
llvm::DenseMap<SubstitutableType *, Type> newParamsMap;
18541854
bool didChange = false;
18551855

18561856
// The upper bounds for the nominal type's arguments may depend on the
@@ -1991,8 +1991,7 @@ class IsBindableVisitor
19911991
SmallVector<ProtocolConformanceRef, 4> paramSubstConformances;
19921992
if (paramUpperBound) {
19931993
for (auto proto : paramUpperBound->getConformsTo()) {
1994-
auto conformance = upperBoundSubstMap.lookupConformance(gp->getCanonicalType(),
1995-
proto);
1994+
auto conformance = upperBoundSubstMap.lookupConformance(gp, proto);
19961995
if (!conformance)
19971996
return CanType();
19981997
paramSubstConformances.push_back(conformance);
@@ -2005,7 +2004,7 @@ class IsBindableVisitor
20052004
return CanType();
20062005

20072006
newParams.push_back(newParam);
2008-
newParamsMap.insert({gpTy, newParam});
2007+
newParamsMap.insert({gp->castTo<GenericTypeParamType>(), newParam});
20092008
didChange |= (newParam != subst);
20102009
}
20112010

@@ -2042,14 +2041,15 @@ class IsBindableVisitor
20422041

20432042
// Gather the conformances for the new binding type, if the type changed.
20442043
if (didChange) {
2045-
auto newSubstTy = newParamsMap.find(req.getFirstType());
2046-
assert(newSubstTy != newParamsMap.end());
2044+
auto newSubstTy = req.getFirstType().subst(
2045+
QueryTypeSubstitutionMap{newParamsMap},
2046+
LookUpConformanceInModule(moduleDecl));
20472047

2048-
if (newSubstTy->second->isTypeParameter()) {
2048+
if (newSubstTy->isTypeParameter()) {
20492049
newConformances.push_back(ProtocolConformanceRef(proto));
20502050
} else {
20512051
auto newConformance
2052-
= moduleDecl->lookupConformance(newSubstTy->second, proto);
2052+
= moduleDecl->lookupConformance(newSubstTy, proto);
20532053
if (!newConformance)
20542054
return CanType();
20552055
newConformances.push_back(newConformance);

0 commit comments

Comments
 (0)