Skip to content

Commit a5a1963

Browse files
committed
Merge pull request #2343 from jckarter/is-bindable-to-conformance-refinement
2 parents 4d43f37 + 225b94a commit a5a1963

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/AST/Type.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,10 +1804,18 @@ static bool isBindableTo(Type a, Type b, LazyResolver *resolver) {
18041804
== substSubs[subi].getConformances().size());
18051805
for (unsigned conformancei :
18061806
indices(origSubs[subi].getConformances())) {
1807-
if (origSubs[subi].getConformances()[conformancei].isConcrete() &&
1808-
origSubs[subi].getConformances()[conformancei] !=
1809-
substSubs[subi].getConformances()[conformancei])
1810-
return false;
1807+
// An abstract conformance can be bound to a concrete one.
1808+
// A concrete conformance may be bindable to a different
1809+
// specialization of the same root conformance.
1810+
auto origConf = origSubs[subi].getConformances()[conformancei],
1811+
substConf = substSubs[subi].getConformances()[conformancei];
1812+
if (origConf.isConcrete()) {
1813+
if (!substConf.isConcrete())
1814+
return false;
1815+
if (origConf.getConcrete()->getRootNormalConformance()
1816+
!= substConf.getConcrete()->getRootNormalConformance())
1817+
return false;
1818+
}
18111819
}
18121820
}
18131821

0 commit comments

Comments
 (0)