diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index 2ae5c6333c10a..21f10b23f3c8d 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -2910,7 +2910,7 @@ bool swift::diagnoseExplicitUnavailability(SourceLoc loc, diags.diagnose(loc, diag::conformance_availability_unavailable, type, proto, platform.empty(), platform, EncodedMessage.Message) - .limitBehavior(behavior) + .limitBehaviorUntilSwiftVersion(behavior, 6) .warnUntilSwiftVersionIf(warnIfConformanceUnavailablePreSwift6, 6); switch (attr->getVersionAvailability(ctx)) { @@ -3468,6 +3468,11 @@ class ExprAvailabilityWalker : public ASTWalker { } } + if (auto UTO = dyn_cast(E)) { + diagnoseSubstitutionMapAvailability( + UTO->getLoc(), UTO->substitutions, Where); + } + if (auto ME = dyn_cast(E)) { diagnoseDeclRefAvailability( ME->getMacroRef(), ME->getMacroNameLoc().getSourceRange()); diff --git a/test/Concurrency/sendable_checking.swift b/test/Concurrency/sendable_checking.swift index aa4dcfc2ba515..5865d6de55806 100644 --- a/test/Concurrency/sendable_checking.swift +++ b/test/Concurrency/sendable_checking.swift @@ -427,3 +427,15 @@ extension ImplicitSendableViaMain { struct TestImplicitSendable: Sendable { var x: ImplicitSendableViaMain } + +struct UnavailableSendable {} + +@available(*, unavailable) +extension UnavailableSendable: Sendable {} +// expected-note@-1 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}} + +@available(SwiftStdlib 5.1, *) +func checkOpaqueType() -> some Sendable { + UnavailableSendable() + // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable; this is an error in the Swift 6 language mode}} +} diff --git a/test/Concurrency/sendable_checking_swift6.swift b/test/Concurrency/sendable_checking_swift6.swift new file mode 100644 index 0000000000000..0ef9dc1bdf80c --- /dev/null +++ b/test/Concurrency/sendable_checking_swift6.swift @@ -0,0 +1,16 @@ +// RUN: %target-swift-frontend -emit-sil -swift-version 6 %s -o /dev/null -verify + +// REQUIRES: concurrency + + +struct UnavailableSendable {} + +@available(*, unavailable) +extension UnavailableSendable: Sendable {} +// expected-note@-1 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}} + +@available(SwiftStdlib 5.1, *) +func checkOpaqueType() -> some Sendable { + UnavailableSendable() + // expected-error@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}} +} diff --git a/test/Sema/availability.swift b/test/Sema/availability.swift index 4ad9596476041..89f370f758a21 100644 --- a/test/Sema/availability.swift +++ b/test/Sema/availability.swift @@ -169,3 +169,14 @@ struct DeferBody { } } +struct NotP {} + +protocol P {} + +@available(*, unavailable) +extension NotP: P {} // expected-note {{conformance of 'NotP' to 'P' has been explicitly marked unavailable here}} + +@available(SwiftStdlib 5.1, *) +func requireP() -> some P { + NotP() // expected-error {{conformance of 'NotP' to 'P' is unavailable}} +}