mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Diagnose an attempt to match non-existential type to an existential one
Resolves: rdar://159401910
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user