Skip to content

Commit fabe70e

Browse files
authored
Merge pull request #79599 from xedin/rdar-145341605
[Concurrency/Diagnostics] A few fixes to diagnostic downgrades and tracking
2 parents 7540abf + 664c119 commit fabe70e

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ InFlightDiagnostic::limitBehaviorUntilSwiftVersion(
440440
limitBehavior(limit);
441441
}
442442

443-
if (majorVersion == 6) {
443+
// Record all of the diagnostics that are going to be emitted.
444+
if (majorVersion == 6 && limit != DiagnosticBehavior::Ignore) {
444445
if (auto stats = Engine->statsReporter) {
445446
++stats->getFrontendCounters().NumSwift6Errors;
446447
}

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,8 +2346,11 @@ diagnosePotentialUnavailability(const RootProtocolConformance *rootConf,
23462346
ctx.getTargetPlatformStringForDiagnostics(),
23472347
availability.getRawMinimumVersion());
23482348

2349-
err.warnUntilSwiftVersion(6);
2350-
err.limitBehavior(behaviorLimitForExplicitUnavailability(rootConf, dc));
2349+
auto behaviorLimit = behaviorLimitForExplicitUnavailability(rootConf, dc);
2350+
if (behaviorLimit >= DiagnosticBehavior::Warning)
2351+
err.limitBehavior(behaviorLimit);
2352+
else
2353+
err.warnUntilSwiftVersion(6);
23512354

23522355
// Direct a fixit to the error if an existing guard is nearly-correct
23532356
if (fixAvailabilityByNarrowingNearbyVersionCheck(loc, dc, availability, ctx,

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,14 +4853,12 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
48534853
bool isUnsafe = attr->isArgUnsafe();
48544854
if (attr->hasArgs()) {
48554855
if (isUnsafe) {
4856-
bool inSwiftinterface = decl->getDeclContext()->isInSwiftinterface();
4857-
ctx.Diags.diagnose(
4858-
attr->getLocation(),
4859-
diag::unsafe_global_actor)
4860-
.fixItRemove(attr->getArgs()->getSourceRange())
4861-
.fixItInsert(attr->getLocation(), "@preconcurrency ")
4862-
.warnUntilSwiftVersion(6)
4863-
.limitBehaviorIf(inSwiftinterface, DiagnosticBehavior::Ignore);
4856+
if (!decl->getDeclContext()->isInSwiftinterface()) {
4857+
ctx.Diags.diagnose(attr->getLocation(), diag::unsafe_global_actor)
4858+
.fixItRemove(attr->getArgs()->getSourceRange())
4859+
.fixItInsert(attr->getLocation(), "@preconcurrency ")
4860+
.warnUntilSwiftVersion(6);
4861+
}
48644862
} else {
48654863
ctx.Diags.diagnose(
48664864
attr->getLocation(),
@@ -6490,11 +6488,14 @@ static bool checkSendableInstanceStorage(
64906488
return true;
64916489
}
64926490

6493-
property->diagnose(diag::non_concurrent_type_member,
6494-
propertyType, false, property->getName(),
6495-
nominal)
6496-
.limitBehaviorUntilSwiftVersion(behavior, 6)
6497-
.limitBehaviorIf(preconcurrency);
6491+
if (preconcurrency)
6492+
behavior = preconcurrency.value();
6493+
6494+
property
6495+
->diagnose(diag::non_concurrent_type_member, propertyType,
6496+
false, property->getName(), nominal)
6497+
.limitBehaviorWithPreconcurrency(behavior,
6498+
preconcurrency.has_value());
64986499
return false;
64996500
});
65006501

@@ -6532,10 +6533,14 @@ static bool checkSendableInstanceStorage(
65326533
return true;
65336534
}
65346535

6535-
element->diagnose(diag::non_concurrent_type_member, type,
6536-
true, element->getName(), nominal)
6537-
.limitBehaviorUntilSwiftVersion(behavior, 6)
6538-
.limitBehaviorIf(preconcurrency);
6536+
if (preconcurrency)
6537+
behavior = preconcurrency.value();
6538+
6539+
element
6540+
->diagnose(diag::non_concurrent_type_member, type, true,
6541+
element->getName(), nominal)
6542+
.limitBehaviorWithPreconcurrency(behavior,
6543+
preconcurrency.has_value());
65396544
return false;
65406545
});
65416546

0 commit comments

Comments
 (0)