diff --git a/include/swift/Basic/Features.def b/include/swift/Basic/Features.def index 500b7648c6e53..5f6c609efcc8c 100644 --- a/include/swift/Basic/Features.def +++ b/include/swift/Basic/Features.def @@ -108,6 +108,7 @@ UPCOMING_FEATURE(ForwardTrailingClosures, 286, 6) UPCOMING_FEATURE(BareSlashRegexLiterals, 354, 6) UPCOMING_FEATURE(ExistentialAny, 335, 6) UPCOMING_FEATURE(ImportObjcForwardDeclarations, 384, 6) +UPCOMING_FEATURE(StrictConcurrency, 337, 6) EXPERIMENTAL_FEATURE(StaticAssert, false) EXPERIMENTAL_FEATURE(VariadicGenerics, false) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 7faf7521c9fc1..a19fa9c53028f 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -3173,6 +3173,10 @@ static bool usesFeatureExistentialAny(Decl *decl) { return false; } +static bool usesFeatureStrictConcurrency(Decl *decl) { + return false; +} + static bool usesFeatureImportObjcForwardDeclarations(Decl *decl) { ClangNode clangNode = decl->getClangNode(); if (!clangNode) diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index ad34f862f5482..d4d2005b8ed49 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -909,6 +909,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, } else if (Args.hasArg(OPT_warn_concurrency)) { Opts.StrictConcurrencyLevel = StrictConcurrency::Complete; + } else if (Opts.hasFeature(Feature::StrictConcurrency)) { + Opts.StrictConcurrencyLevel = StrictConcurrency::Complete; } else { // Default to minimal checking in Swift 5.x. Opts.StrictConcurrencyLevel = StrictConcurrency::Minimal; diff --git a/test/Concurrency/upcoming_feature_strictconcurrency.swift b/test/Concurrency/upcoming_feature_strictconcurrency.swift new file mode 100644 index 0000000000000..7f81fe5b77b9c --- /dev/null +++ b/test/Concurrency/upcoming_feature_strictconcurrency.swift @@ -0,0 +1,21 @@ +// RUN: %target-typecheck-verify-swift -enable-upcoming-feature StrictConcurrency +// REQUIRES: concurrency + +class C1 { } // expected-note{{class 'C1' does not conform to the 'Sendable' protocol}} +class C2 { } + +@available(*, unavailable) +extension C2: Sendable {} // expected-note{{conformance of 'C2' to 'Sendable' has been explicitly marked unavailable here}} + +protocol TestProtocol { + associatedtype Value: Sendable +} + +struct Test1: TestProtocol { // expected-warning{{type 'Test1.Value' (aka 'C1') does not conform to the 'Sendable' protocol}} + typealias Value = C1 +} + +struct Test2: TestProtocol { // expected-warning{{conformance of 'C2' to 'Sendable' is unavailable}} + // expected-note@-1{{in associated type 'Self.Value' (inferred as 'C2')}} + typealias Value = C2 +}