Skip to content

Commit abac604

Browse files
committed
AST: Fix SubstitutionMap::getOverrideSubstitutions() for generic protocol requirements
We need a substitution map written in terms of the base requirement's signature; getProtocolSubstitutions() alone was not enough because it does not include the extra generic parameters that the base requirement might have if it is itself generic.
1 parent 0b10948 commit abac604

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/AST/SubstitutionMap.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,9 @@ SubstitutionMap::getOverrideSubstitutions(
511511
Optional<SubstitutionMap> derivedSubs) {
512512
// For overrides within a protocol hierarchy, substitute the Self type.
513513
if (auto baseProto = baseDecl->getDeclContext()->getSelfProtocolDecl()) {
514-
if (auto derivedProtoSelf =
515-
derivedDecl->getDeclContext()->getSelfInterfaceType()) {
516-
return SubstitutionMap::getProtocolSubstitutions(
517-
baseProto,
518-
derivedProtoSelf,
519-
ProtocolConformanceRef(baseProto));
520-
}
521-
522-
return SubstitutionMap();
514+
auto baseSig = baseDecl->getInnermostDeclContext()
515+
->getGenericSignatureOfContext();
516+
return baseSig->getIdentitySubstitutionMap();
523517
}
524518

525519
auto *baseClass = baseDecl->getDeclContext()->getSelfClassDecl();

0 commit comments

Comments
 (0)