Skip to content

Commit 3b44046

Browse files
authored
Merge pull request #70935 from hborla/5.10-downgrade-isolated-default-expr-error
[5.10][Concurrency] Downgrade `isolated_default_argument_context` to a warning until Swift 6 for stored properties.
2 parents d284d95 + 811426a commit 3b44046

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4856,7 +4856,8 @@ DefaultInitializerIsolation::evaluate(Evaluator &evaluator,
48564856
if (enclosingIsolation != requiredIsolation) {
48574857
var->diagnose(
48584858
diag::isolated_default_argument_context,
4859-
requiredIsolation, enclosingIsolation);
4859+
requiredIsolation, enclosingIsolation)
4860+
.warnUntilSwiftVersionIf(!isa<ParamDecl>(var), 6);
48604861
return ActorIsolation::forUnspecified();
48614862
}
48624863
}

test/Concurrency/actor_isolation.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -784,15 +784,15 @@ actor LazyActor {
784784
lazy var l25: Int = { [unowned self] in self.l }()
785785

786786
nonisolated lazy var l31: Int = { v }()
787-
// expected-error@-1 {{actor-isolated default value in a nonisolated context}}
787+
// expected-warning@-1 {{actor-isolated default value in a nonisolated context; this is an error in Swift 6}}
788788
nonisolated lazy var l32: Int = v
789-
// expected-error@-1 {{actor-isolated default value in a nonisolated context}}
789+
// expected-warning@-1 {{actor-isolated default value in a nonisolated context; this is an error in Swift 6}}
790790
nonisolated lazy var l33: Int = { self.v }()
791-
// expected-error@-1 {{actor-isolated default value in a nonisolated context}}
791+
// expected-warning@-1 {{actor-isolated default value in a nonisolated context; this is an error in Swift 6}}
792792
nonisolated lazy var l34: Int = self.v
793-
// expected-error@-1 {{actor-isolated default value in a nonisolated context}}
793+
// expected-warning@-1 {{actor-isolated default value in a nonisolated context; this is an error in Swift 6}}
794794
nonisolated lazy var l35: Int = { [unowned self] in self.v }()
795-
// expected-error@-1 {{actor-isolated default value in a nonisolated context}}
795+
// expected-warning@-1 {{actor-isolated default value in a nonisolated context; this is an error in Swift 6}}
796796

797797
nonisolated lazy var l41: Int = { l }()
798798
nonisolated lazy var l42: Int = l

test/Concurrency/global_actor_inference.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ actor ActorWithWrapper {
444444
@WrapperOnActor var synced: Int = 0
445445
// expected-note@-1 3{{property declared here}}
446446
@WrapperWithMainActorDefaultInit var property: Int // expected-minimal-targeted-error {{call to main actor-isolated initializer 'init()' in a synchronous actor-isolated context}}
447-
// expected-complete-sns-error@-1 {{main actor-isolated default value in a actor-isolated context}}
447+
// expected-complete-sns-warning@-1 {{main actor-isolated default value in a actor-isolated context; this is an error in Swift 6}}
448448
func f() {
449449
_ = synced // expected-error{{main actor-isolated property 'synced' can not be referenced on a different actor instance}}
450450
_ = $synced // expected-error{{global actor 'SomeGlobalActor'-isolated property '$synced' can not be referenced on a different actor instance}}
@@ -560,7 +560,7 @@ struct WrapperOnUnsafeActor<Wrapped> {
560560

561561
// HasWrapperOnUnsafeActor gets an inferred @MainActor attribute.
562562
struct HasWrapperOnUnsafeActor {
563-
@WrapperOnUnsafeActor var synced: Int = 0 // expected-complete-sns-error {{global actor 'OtherGlobalActor'-isolated default value in a main actor-isolated context}}
563+
@WrapperOnUnsafeActor var synced: Int = 0 // expected-complete-sns-warning {{global actor 'OtherGlobalActor'-isolated default value in a main actor-isolated context; this is an error in Swift 6}}
564564
// expected-note @-1 3{{property declared here}}
565565
// expected-complete-sns-note @-2 3{{property declared here}}
566566

@@ -680,10 +680,10 @@ class Cutter {
680680
@SomeGlobalActor
681681
class Butter {
682682
var a = useFooInADefer() // expected-minimal-targeted-error {{call to main actor-isolated global function 'useFooInADefer()' in a synchronous global actor 'SomeGlobalActor'-isolated context}}
683-
// expected-complete-sns-error@-1 {{main actor-isolated default value in a global actor 'SomeGlobalActor'-isolated context}}
683+
// expected-complete-sns-warning@-1 {{main actor-isolated default value in a global actor 'SomeGlobalActor'-isolated context; this is an error in Swift 6}}
684684

685685
nonisolated let b = statefulThingy // expected-minimal-targeted-error {{main actor-isolated var 'statefulThingy' can not be referenced from a non-isolated context}}
686-
// expected-complete-sns-error@-1 {{main actor-isolated default value in a nonisolated context}}
686+
// expected-complete-sns-warning@-1 {{main actor-isolated default value in a nonisolated context; this is an error in Swift 6}}}
687687

688688
var c: Int = {
689689
return getGlobal7()

test/Concurrency/isolated_default_arguments.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct S3 {
156156
}
157157

158158
struct S4 {
159-
// expected-error@+1 {{main actor-isolated default value in a nonisolated context}}
159+
// expected-warning@+1 {{main actor-isolated default value in a nonisolated context; this is an error in Swift 6}}
160160
var x: Int = requiresMainActor()
161161
}
162162

0 commit comments

Comments
 (0)