Skip to content

Commit 7ccb2c1

Browse files
authored
Merge pull request #79601 from xedin/rdar-145341605-6.1
[6.1][Concurrency/Diagnostics] A few fixes to diagnostic downgrades and tracking
2 parents 5095808 + 9fda610 commit 7ccb2c1

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ InFlightDiagnostic::limitBehaviorUntilSwiftVersion(
432432
limitBehavior(limit);
433433
}
434434

435-
if (majorVersion == 6) {
435+
// Record all of the diagnostics that are going to be emitted.
436+
if (majorVersion == 6 && limit != DiagnosticBehavior::Ignore) {
436437
if (auto stats = Engine->statsReporter) {
437438
++stats->getFrontendCounters().NumSwift6Errors;
438439
}

lib/Sema/TypeCheckAvailability.cpp

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

2310-
err.warnUntilSwiftVersion(6);
2311-
err.limitBehavior(behaviorLimitForExplicitUnavailability(rootConf, dc));
2310+
auto behaviorLimit = behaviorLimitForExplicitUnavailability(rootConf, dc);
2311+
if (behaviorLimit >= DiagnosticBehavior::Warning)
2312+
err.limitBehavior(behaviorLimit);
2313+
else
2314+
err.warnUntilSwiftVersion(6);
23122315

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

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4819,13 +4819,12 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
48194819
SourceFile *file = decl->getDeclContext()->getParentSourceFile();
48204820
bool inSwiftinterface =
48214821
file && file->Kind == SourceFileKind::Interface;
4822-
ctx.Diags.diagnose(
4823-
attr->getLocation(),
4824-
diag::unsafe_global_actor)
4825-
.fixItRemove(attr->getArgs()->getSourceRange())
4826-
.fixItInsert(attr->getLocation(), "@preconcurrency ")
4827-
.warnUntilSwiftVersion(6)
4828-
.limitBehaviorIf(inSwiftinterface, DiagnosticBehavior::Ignore);
4822+
if (!inSwiftinterface) {
4823+
ctx.Diags.diagnose(attr->getLocation(), diag::unsafe_global_actor)
4824+
.fixItRemove(attr->getArgs()->getSourceRange())
4825+
.fixItInsert(attr->getLocation(), "@preconcurrency ")
4826+
.warnUntilSwiftVersion(6);
4827+
}
48294828
} else {
48304829
ctx.Diags.diagnose(
48314830
attr->getLocation(),
@@ -6383,11 +6382,14 @@ static bool checkSendableInstanceStorage(
63836382
return true;
63846383
}
63856384

6386-
property->diagnose(diag::non_concurrent_type_member,
6387-
propertyType, false, property->getName(),
6388-
nominal)
6389-
.limitBehaviorUntilSwiftVersion(behavior, 6)
6390-
.limitBehaviorIf(preconcurrency);
6385+
if (preconcurrency)
6386+
behavior = preconcurrency.value();
6387+
6388+
property
6389+
->diagnose(diag::non_concurrent_type_member, propertyType,
6390+
false, property->getName(), nominal)
6391+
.limitBehaviorWithPreconcurrency(behavior,
6392+
preconcurrency.has_value());
63916393
return false;
63926394
});
63936395

@@ -6425,10 +6427,14 @@ static bool checkSendableInstanceStorage(
64256427
return true;
64266428
}
64276429

6428-
element->diagnose(diag::non_concurrent_type_member, type,
6429-
true, element->getName(), nominal)
6430-
.limitBehaviorUntilSwiftVersion(behavior, 6)
6431-
.limitBehaviorIf(preconcurrency);
6430+
if (preconcurrency)
6431+
behavior = preconcurrency.value();
6432+
6433+
element
6434+
->diagnose(diag::non_concurrent_type_member, type, true,
6435+
element->getName(), nominal)
6436+
.limitBehaviorWithPreconcurrency(behavior,
6437+
preconcurrency.has_value());
64326438
return false;
64336439
});
64346440

0 commit comments

Comments
 (0)