Skip to content

Commit 68932a6

Browse files
authored
Merge pull request #66974 from DougGregor/se-0401-property-wrapper-isolation-disable
2 parents 8cb488d + 2628645 commit 68932a6

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ UPCOMING_FEATURE(ForwardTrailingClosures, 286, 6)
113113
UPCOMING_FEATURE(BareSlashRegexLiterals, 354, 6)
114114
UPCOMING_FEATURE(ExistentialAny, 335, 6)
115115
UPCOMING_FEATURE(ImportObjcForwardDeclarations, 384, 6)
116+
UPCOMING_FEATURE(DisableActorInferenceFromPropertyWrapperUsage, 0, 6)
116117

117118
EXPERIMENTAL_FEATURE(StaticAssert, false)
118119
EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false)

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,6 +3351,10 @@ static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {
33513351
return macro->getMacroRoles().contains(MacroRole::Expression);
33523352
}
33533353

3354+
static bool usesFeatureDisableActorInferenceFromPropertyWrapperUsage(Decl *decl) {
3355+
return false;
3356+
}
3357+
33543358
static void
33553359
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
33563360
llvm::function_ref<void()> action) {

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,8 +3655,15 @@ static Optional<ActorIsolation> getIsolationFromWrappers(
36553655
return None;
36563656

36573657
if (!nominal->getParentSourceFile())
3658-
return None;
3659-
3658+
return llvm::None;
3659+
3660+
ASTContext &ctx = nominal->getASTContext();
3661+
if (ctx.LangOpts.hasFeature(Feature::DisableActorInferenceFromPropertyWrapperUsage)) {
3662+
// In Swift 6, we no longer infer isolation of a nominal type
3663+
// based on the property wrappers used in its stored properties
3664+
return llvm::None;
3665+
}
3666+
36603667
Optional<ActorIsolation> foundIsolation;
36613668
for (auto member : nominal->getMembers()) {
36623669
auto var = dyn_cast<VarDecl>(member);
@@ -4270,8 +4277,8 @@ ActorIsolation ActorIsolationRequest::evaluate(
42704277
if (auto inferred = inferredIsolation(*conformanceIsolation))
42714278
return inferred;
42724279

4273-
// If the declaration is a nominal type and any property wrappers on
4274-
// its stored properties require isolation, use that.
4280+
// Before Swift 6: If the declaration is a nominal type and any property
4281+
// wrappers on its stored properties require isolation, use that.
42754282
if (auto wrapperIsolation = getIsolationFromWrappers(nominal)) {
42764283
if (auto inferred = inferredIsolation(*wrapperIsolation))
42774284
return inferred;

test/Concurrency/global_actor_inference_swift6.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct HasMainActorWrappedProp {
7878

7979
var plainStorage: Int
8080

81-
var computedProp: Int { 0 } // expected-note {{property declared here}}
81+
var computedProp: Int { 0 }
8282

8383
nonisolated func testErrors() {
8484
_ = thing // expected-error {{main actor-isolated property 'thing' can not be referenced from a non-isolated context}}
@@ -89,7 +89,7 @@ struct HasMainActorWrappedProp {
8989

9090
_ = plainStorage
9191

92-
_ = computedProp // expected-error {{main actor-isolated property 'computedProp' can not be referenced from a non-isolated context}}
92+
_ = computedProp
9393
}
9494
}
9595

0 commit comments

Comments
 (0)