Skip to content

Commit ea6533c

Browse files
committed
[NFC][Test] Add tests for actor isolation checking for local property
wrapper default initializers.
1 parent 8d65bcf commit ea6533c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/Concurrency/global_actor_inference.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,22 @@ actor WrapperActorBad2<Wrapped> {
374374
}
375375
}
376376

377+
@propertyWrapper
378+
struct WrapperWithMainActorDefaultInit {
379+
var wrappedValue: Int { fatalError() }
380+
381+
@MainActor init() {} // expected-note {{calls to initializer 'init()' from outside of its actor context are implicitly asynchronous}}
382+
}
383+
377384
actor ActorWithWrapper {
378385
@WrapperOnActor var synced: Int = 0
379386
// expected-note@-1 3{{property declared here}}
380387
func f() {
381388
_ = synced // expected-error{{'synced' isolated to global actor}}
382389
_ = $synced // expected-error{{'$synced' isolated to global actor}}
383390
_ = _synced // expected-error{{'_synced' isolated to global actor}}
391+
392+
@WrapperWithMainActorDefaultInit var value: Int // expected-error {{call to main actor-isolated initializer 'init()' in a synchronous actor-isolated context}}
384393
}
385394
}
386395

0 commit comments

Comments
 (0)