Skip to content

Commit 06984b4

Browse files
authored
Merge pull request #68964 from xedin/rdar-113675093
[CSSimplify] Determine whether type is know Foundation entity in a sa…
2 parents 0b2048d + b83a73d commit 06984b4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/Sema/CSSimplify.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -2761,10 +2761,17 @@ assessRequirementFailureImpact(ConstraintSystem &cs, Type requirementType,
27612761
if (locator.isForRequirement(RequirementKind::Conformance)) {
27622762
// Increase the impact of a conformance fix for a standard library
27632763
// or foundation type, as it's unlikely to be a good suggestion.
2764-
if (resolvedTy->isStdlibType() ||
2765-
getKnownFoundationEntity(resolvedTy->getString())) {
2766-
impact += 2;
2764+
{
2765+
if (resolvedTy->isStdlibType()) {
2766+
impact += 2;
2767+
}
2768+
2769+
if (auto *NTD = resolvedTy->getAnyNominal()) {
2770+
if (getKnownFoundationEntity(NTD->getNameStr()))
2771+
impact += 2;
2772+
}
27672773
}
2774+
27682775
// Also do the same for the builtin compiler types Any and AnyObject, but
27692776
// bump the impact even higher as they cannot conform to protocols at all.
27702777
if (resolvedTy->isAny() || resolvedTy->isAnyObject())

0 commit comments

Comments
 (0)