diff --git a/lib/AST/DiagnosticEngine.cpp b/lib/AST/DiagnosticEngine.cpp index 599ff14369719..c6722f803f638 100644 --- a/lib/AST/DiagnosticEngine.cpp +++ b/lib/AST/DiagnosticEngine.cpp @@ -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; } diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index d40670b627c4c..e58ae673d8afc 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -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, diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 084196654c246..b989ce887f1ce 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -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(), @@ -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; }); @@ -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; });