Skip to content

Commit 3ebf633

Browse files
committed
[ConstraintSystem] Increase impact of conformance failure associated with a known foundation type
Just like we already do for stdlib types, extend impact of missing conformances on _known_ foundation types because it's unlikely to be a valid suggestion to extend a foundation type with a new conformance.
1 parent d23b938 commit 3ebf633

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,17 +1489,21 @@ assessRequirementFailureImpact(ConstraintSystem &cs, Type requirementType,
14891489
return 10;
14901490
}
14911491

1492-
// Increase the impact of a conformance fix for a standard library type,
1493-
// as it's unlikely to be a good suggestion. Also do the same for the builtin
1494-
// compiler types Any and AnyObject, which cannot conform to protocols.
1492+
// Increase the impact of a conformance fix for a standard library
1493+
// or foundation type, as it's unlikely to be a good suggestion.
1494+
//
1495+
// Also do the same for the builtin compiler types Any and AnyObject,
1496+
// which cannot conform to protocols.
1497+
//
14951498
// FIXME: We ought not to have the is<TypeVariableType>() condition here, but
14961499
// removing it currently regresses the diagnostic for the test case for
14971500
// rdar://60727310. Once we better handle the separation of conformance fixes
14981501
// from argument mismatches in cases like SR-12438, we should be able to
14991502
// remove it from the condition.
15001503
auto resolvedTy = cs.simplifyType(requirementType);
15011504
if ((requirementType->is<TypeVariableType>() && resolvedTy->isStdlibType()) ||
1502-
resolvedTy->isAny() || resolvedTy->isAnyObject()) {
1505+
resolvedTy->isAny() || resolvedTy->isAnyObject() ||
1506+
getKnownFoundationEntity(resolvedTy->getString())) {
15031507
if (auto last = locator.last()) {
15041508
if (auto requirement = last->getAs<LocatorPathElt::AnyRequirement>()) {
15051509
auto kind = requirement->getRequirementKind();

0 commit comments

Comments
 (0)