diff --git a/lib/AST/DiagnosticEngine.cpp b/lib/AST/DiagnosticEngine.cpp index c840fec4ec337..b239071cad903 100644 --- a/lib/AST/DiagnosticEngine.cpp +++ b/lib/AST/DiagnosticEngine.cpp @@ -432,7 +432,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 f784a1e9831f9..92ee4533316e7 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -2307,8 +2307,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 f52c57489dc14..aa0999efa7abf 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -4819,13 +4819,12 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true, SourceFile *file = decl->getDeclContext()->getParentSourceFile(); bool inSwiftinterface = file && file->Kind == SourceFileKind::Interface; - ctx.Diags.diagnose( - attr->getLocation(), - diag::unsafe_global_actor) - .fixItRemove(attr->getArgs()->getSourceRange()) - .fixItInsert(attr->getLocation(), "@preconcurrency ") - .warnUntilSwiftVersion(6) - .limitBehaviorIf(inSwiftinterface, DiagnosticBehavior::Ignore); + if (!inSwiftinterface) { + 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(), @@ -6383,11 +6382,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; }); @@ -6425,10 +6427,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; });