Skip to content

Commit 637230d

Browse files
authored
Merge pull request swiftlang#20662 from rjmccall/clone-ex-sub-map-self-conf
Fix a source-compatibility bug in swiftlang#20658
2 parents 6d6b3cd + 72e5fc2 commit 637230d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/AST/ProtocolConformance.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,21 @@ ProtocolConformanceRef::subst(Type origType,
114114

115115
auto *proto = getRequirement();
116116

117+
// If the type is an existential, it must be self-conforming.
118+
if (substType->isExistentialType()) {
119+
auto optConformance =
120+
proto->getModuleContext()->lookupExistentialConformance(substType, proto);
121+
assert(optConformance && "existential type didn't self-conform");
122+
return *optConformance;
123+
}
124+
117125
// Check the conformance map.
118126
if (auto result = conformances(origType->getCanonicalType(),
119127
substType, proto)) {
120128
return *result;
121129
}
122130

123-
// The only remaining case is that the type is an existential that
124-
// self-conforms.
125-
assert(substType->isExistentialType());
126-
auto optConformance =
127-
proto->getModuleContext()->lookupExistentialConformance(substType, proto);
128-
assert(optConformance && "existential type didn't self-conform");
129-
return *optConformance;
131+
llvm_unreachable("Invalid conformance substitution");
130132
}
131133

132134
Type

0 commit comments

Comments
 (0)