[CSSimplify] Diagnose an attempt to match non-existential type to an existential one

Resolves: rdar://159401910
This commit is contained in:
Pavel Yaskevich
2025-10-06 09:47:14 -07:00
parent af909078e5
commit 36fc1e6c43
2 changed files with 24 additions and 5 deletions

View File

@@ -8750,7 +8750,27 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
return SolutionKind::Solved;
}
return matchExistentialTypes(type, protocol, kind, flags, locator);
auto result = matchExistentialTypes(type, protocol, kind, flags, locator);
if (shouldAttemptFixes() && result.isFailure()) {
auto *loc = getConstraintLocator(locator);
if (loc->isLastElement<LocatorPathElt::InstanceType>())
loc = getConstraintLocator(loc->getAnchor(), loc->getPath().drop_back());
ConstraintFix *fix = nullptr;
if (loc->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
fix = AllowArgumentMismatch::create(*this, type, protocol, loc);
} else if (loc->isLastElement<LocatorPathElt::ContextualType>()) {
fix = ContextualMismatch::create(*this, type, protocol, loc);
}
if (fix) {
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
}
}
return result;
}
void ConstraintSystem::recordSynthesizedConformance(