mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Fix generics invariant violations in override checking
Override checking checks if the derived declaration's generic signature is compatible with the base, but it does this after doing a bunch of other checks which feed potentially invalid type parameters to generic signature queries. Now that the requirement machine is stricter about this kind of this, re-organize some code to get around this. Unfortunately this regresses a diagnostic, because we reject candidates with mismatched generic requirements earlier in the process.
This commit is contained in:
@@ -541,8 +541,9 @@ computeDesignatedInitOverrideSignature(ASTContext &ctx,
|
||||
auto lookupConformanceFn =
|
||||
[&](CanType depTy, Type substTy,
|
||||
ProtocolDecl *proto) -> ProtocolConformanceRef {
|
||||
if (auto conf = subMap.lookupConformance(depTy, proto))
|
||||
return conf;
|
||||
if (depTy->getRootGenericParam()->getDepth() < superclassDepth)
|
||||
if (auto conf = subMap.lookupConformance(depTy, proto))
|
||||
return conf;
|
||||
|
||||
return ProtocolConformanceRef(proto);
|
||||
};
|
||||
@@ -1125,9 +1126,7 @@ static void addImplicitInheritedConstructorsToClass(ClassDecl *decl) {
|
||||
continue;
|
||||
|
||||
auto type = swift::getMemberTypeForComparison(ctor, nullptr);
|
||||
auto parentType = swift::getMemberTypeForComparison(superclassCtor, ctor);
|
||||
|
||||
if (isOverrideBasedOnType(ctor, type, superclassCtor, parentType)) {
|
||||
if (isOverrideBasedOnType(ctor, type, superclassCtor)) {
|
||||
alreadyDeclared = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user