mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
This commit is contained in:
@@ -511,15 +511,9 @@ SubstitutionMap::getOverrideSubstitutions(
|
||||
Optional<SubstitutionMap> derivedSubs) {
|
||||
// For overrides within a protocol hierarchy, substitute the Self type.
|
||||
if (auto baseProto = baseDecl->getDeclContext()->getSelfProtocolDecl()) {
|
||||
if (auto derivedProtoSelf =
|
||||
derivedDecl->getDeclContext()->getSelfInterfaceType()) {
|
||||
return SubstitutionMap::getProtocolSubstitutions(
|
||||
baseProto,
|
||||
derivedProtoSelf,
|
||||
ProtocolConformanceRef(baseProto));
|
||||
}
|
||||
|
||||
return SubstitutionMap();
|
||||
auto baseSig = baseDecl->getInnermostDeclContext()
|
||||
->getGenericSignatureOfContext();
|
||||
return baseSig->getIdentitySubstitutionMap();
|
||||
}
|
||||
|
||||
auto *baseClass = baseDecl->getDeclContext()->getSelfClassDecl();
|
||||
|
||||
Reference in New Issue
Block a user