mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #26536 from theblixguy/fix/SR-10198
[Typechecker] Check for generic signature when matching overrides
This commit is contained in:
@@ -4408,6 +4408,7 @@ GenericSignature *
|
||||
ASTContext::getOverrideGenericSignature(const ValueDecl *base,
|
||||
const ValueDecl *derived) {
|
||||
auto baseGenericCtx = base->getAsGenericContext();
|
||||
auto derivedGenericCtx = derived->getAsGenericContext();
|
||||
auto &ctx = base->getASTContext();
|
||||
|
||||
if (!baseGenericCtx) {
|
||||
@@ -4431,6 +4432,10 @@ ASTContext::getOverrideGenericSignature(const ValueDecl *base,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!derivedGenericCtx || !derivedGenericCtx->isGeneric()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (derivedClass->getGenericSignature() == nullptr &&
|
||||
!baseGenericCtx->isGeneric()) {
|
||||
return nullptr;
|
||||
@@ -4459,12 +4464,8 @@ ASTContext::getOverrideGenericSignature(const ValueDecl *base,
|
||||
GenericSignatureBuilder builder(ctx);
|
||||
builder.addGenericSignature(derivedClass->getGenericSignature());
|
||||
|
||||
if (auto derivedGenericCtx = derived->getAsGenericContext()) {
|
||||
if (derivedGenericCtx->isGeneric()) {
|
||||
for (auto param : *derivedGenericCtx->getGenericParams()) {
|
||||
builder.addGenericParameter(param);
|
||||
}
|
||||
}
|
||||
for (auto param : *derivedGenericCtx->getGenericParams()) {
|
||||
builder.addGenericParameter(param);
|
||||
}
|
||||
|
||||
auto source =
|
||||
|
||||
Reference in New Issue
Block a user