Skip to content

[Concurrency/Diagnostics] A few fixes to diagnostic downgrades and tracking #79599

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 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ InFlightDiagnostic::limitBehaviorUntilSwiftVersion(
limitBehavior(limit);
}

if (majorVersion == 6) {
// Record all of the diagnostics that are going to be emitted.
if (majorVersion == 6 && limit != DiagnosticBehavior::Ignore) {
if (auto stats = Engine->statsReporter) {
++stats->getFrontendCounters().NumSwift6Errors;
}
Expand Down
7 changes: 5 additions & 2 deletions lib/Sema/TypeCheckAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2337,8 +2337,11 @@ diagnosePotentialUnavailability(const RootProtocolConformance *rootConf,
ctx.getTargetPlatformStringForDiagnostics(),
availability.getRawMinimumVersion());

err.warnUntilSwiftVersion(6);
err.limitBehavior(behaviorLimitForExplicitUnavailability(rootConf, dc));
auto behaviorLimit = behaviorLimitForExplicitUnavailability(rootConf, dc);
if (behaviorLimit >= DiagnosticBehavior::Warning)
err.limitBehavior(behaviorLimit);
else
err.warnUntilSwiftVersion(6);

// Direct a fixit to the error if an existing guard is nearly-correct
if (fixAvailabilityByNarrowingNearbyVersionCheck(loc, dc, availability, ctx,
Expand Down
39 changes: 22 additions & 17 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4853,14 +4853,12 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
bool isUnsafe = attr->isArgUnsafe();
if (attr->hasArgs()) {
if (isUnsafe) {
bool inSwiftinterface = decl->getDeclContext()->isInSwiftinterface();
ctx.Diags.diagnose(
attr->getLocation(),
diag::unsafe_global_actor)
.fixItRemove(attr->getArgs()->getSourceRange())
.fixItInsert(attr->getLocation(), "@preconcurrency ")
.warnUntilSwiftVersion(6)
.limitBehaviorIf(inSwiftinterface, DiagnosticBehavior::Ignore);
if (!decl->getDeclContext()->isInSwiftinterface()) {
ctx.Diags.diagnose(attr->getLocation(), diag::unsafe_global_actor)
.fixItRemove(attr->getArgs()->getSourceRange())
.fixItInsert(attr->getLocation(), "@preconcurrency ")
.warnUntilSwiftVersion(6);
}
} else {
ctx.Diags.diagnose(
attr->getLocation(),
Expand Down Expand Up @@ -6490,11 +6488,14 @@ static bool checkSendableInstanceStorage(
return true;
}

property->diagnose(diag::non_concurrent_type_member,
propertyType, false, property->getName(),
nominal)
.limitBehaviorUntilSwiftVersion(behavior, 6)
.limitBehaviorIf(preconcurrency);
if (preconcurrency)
behavior = preconcurrency.value();

property
->diagnose(diag::non_concurrent_type_member, propertyType,
false, property->getName(), nominal)
.limitBehaviorWithPreconcurrency(behavior,
preconcurrency.has_value());
return false;
});

Expand Down Expand Up @@ -6532,10 +6533,14 @@ static bool checkSendableInstanceStorage(
return true;
}

element->diagnose(diag::non_concurrent_type_member, type,
true, element->getName(), nominal)
.limitBehaviorUntilSwiftVersion(behavior, 6)
.limitBehaviorIf(preconcurrency);
if (preconcurrency)
behavior = preconcurrency.value();

element
->diagnose(diag::non_concurrent_type_member, type, true,
element->getName(), nominal)
.limitBehaviorWithPreconcurrency(behavior,
preconcurrency.has_value());
return false;
});

Expand Down