Skip to content

[CSSimplify] Determine whether type is know Foundation entity in a sa… #68964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2761,10 +2761,17 @@ assessRequirementFailureImpact(ConstraintSystem &cs, Type requirementType,
if (locator.isForRequirement(RequirementKind::Conformance)) {
// Increase the impact of a conformance fix for a standard library
// or foundation type, as it's unlikely to be a good suggestion.
if (resolvedTy->isStdlibType() ||
getKnownFoundationEntity(resolvedTy->getString())) {
impact += 2;
{
if (resolvedTy->isStdlibType()) {
impact += 2;
}

if (auto *NTD = resolvedTy->getAnyNominal()) {
if (getKnownFoundationEntity(NTD->getNameStr()))
impact += 2;
}
}

// Also do the same for the builtin compiler types Any and AnyObject, but
// bump the impact even higher as they cannot conform to protocols at all.
if (resolvedTy->isAny() || resolvedTy->isAnyObject())
Expand Down