Skip to content

Commit 0d4a585

Browse files
authored
Merge pull request #21509 from DougGregor/submap-superclass-conformance
[Substitution map] When the superclass conforms to a protocol directly use it
2 parents c4941fb + 4f5d2d3 commit 0d4a585

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/AST/SubstitutionMap.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,19 +352,17 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
352352
return None;
353353
};
354354

355+
// Check whether the superclass conforms.
356+
if (auto superclass = genericSig->getSuperclassBound(type)) {
357+
LookUpConformanceInSignature lookup(*getGenericSignature());
358+
if (auto conformance = lookup(type->getCanonicalType(), superclass, proto))
359+
return conformance;
360+
}
361+
355362
// If the type doesn't conform to this protocol, the result isn't formed
356363
// from these requirements.
357-
if (!genericSig->conformsToProtocol(type, proto)) {
358-
// Check whether the superclass conforms.
359-
if (auto superclass = genericSig->getSuperclassBound(type)) {
360-
return LookUpConformanceInSignature(*getGenericSignature())(
361-
type->getCanonicalType(),
362-
superclass,
363-
proto);
364-
}
365-
364+
if (!genericSig->conformsToProtocol(type, proto))
366365
return None;
367-
}
368366

369367
auto accessPath =
370368
genericSig->getConformanceAccessPath(type, proto);

0 commit comments

Comments
 (0)