diff --git a/include/swift/Basic/Features.def b/include/swift/Basic/Features.def index ae44f54cf74ad..6374dea921d46 100644 --- a/include/swift/Basic/Features.def +++ b/include/swift/Basic/Features.def @@ -114,6 +114,7 @@ UPCOMING_FEATURE(ForwardTrailingClosures, 286, 6) UPCOMING_FEATURE(BareSlashRegexLiterals, 354, 6) UPCOMING_FEATURE(ExistentialAny, 335, 6) UPCOMING_FEATURE(ImportObjcForwardDeclarations, 384, 6) +UPCOMING_FEATURE(DisableActorInferenceFromPropertyWrapperUsage, 401, 6) EXPERIMENTAL_FEATURE(StaticAssert, false) EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 221d294839311..cb5c3e8bf4918 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -3346,6 +3346,11 @@ static bool usesFeatureBuiltinMacros(Decl *decl) { return false; } + +static bool usesFeatureDisableActorInferenceFromPropertyWrapperUsage(Decl *decl) { + return false; +} + static bool usesFeatureImportSymbolicCXXDecls(Decl *decl) { return false; } static bool usesFeatureGenerateBindingsForThrowingFunctionsInCXX(Decl *decl) { diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 0f5bec68fd7e0..58d2a4b6ad9a7 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -3653,6 +3653,13 @@ getIsolationFromWrappers(NominalTypeDecl *nominal) { if (!nominal->getParentSourceFile()) return llvm::None; + ASTContext &ctx = nominal->getASTContext(); + if (ctx.LangOpts.hasFeature(Feature::DisableActorInferenceFromPropertyWrapperUsage)) { + // In Swift 6, we no longer infer isolation of a nominal type + // based on the property wrappers used in its stored properties + return llvm::None; + } + llvm::Optional foundIsolation; for (auto member : nominal->getMembers()) { auto var = dyn_cast(member); @@ -4266,8 +4273,8 @@ ActorIsolation ActorIsolationRequest::evaluate( if (auto inferred = inferredIsolation(*conformanceIsolation)) return inferred; - // If the declaration is a nominal type and any property wrappers on - // its stored properties require isolation, use that. + // Before Swift 6: If the declaration is a nominal type and any property + // wrappers on its stored properties require isolation, use that. if (auto wrapperIsolation = getIsolationFromWrappers(nominal)) { if (auto inferred = inferredIsolation(*wrapperIsolation)) return inferred; diff --git a/test/Concurrency/global_actor_inference_swift6.swift b/test/Concurrency/global_actor_inference_swift6.swift index 6e2624dd26cc2..f195912bd5642 100644 --- a/test/Concurrency/global_actor_inference_swift6.swift +++ b/test/Concurrency/global_actor_inference_swift6.swift @@ -78,7 +78,7 @@ struct HasMainActorWrappedProp { var plainStorage: Int - var computedProp: Int { 0 } // expected-note {{property declared here}} + var computedProp: Int { 0 } nonisolated func testErrors() { _ = thing // expected-error {{main actor-isolated property 'thing' can not be referenced from a non-isolated context}} @@ -89,7 +89,7 @@ struct HasMainActorWrappedProp { _ = plainStorage - _ = computedProp // expected-error {{main actor-isolated property 'computedProp' can not be referenced from a non-isolated context}} + _ = computedProp } }