Skip to content

Commit 7dcbc96

Browse files
committed
[Test] Add some test cases
1 parent 1a6b333 commit 7dcbc96

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/Concurrency/global_actor_inference.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,51 @@ func testInferredFromWrapper(x: InferredFromPropertyWrapper) { // expected-note{
457457
_ = x.test() // expected-error{{call to global actor 'SomeGlobalActor'-isolated instance method 'test()' in a synchronous nonisolated context}}
458458
}
459459

460+
@propertyWrapper
461+
struct SimplePropertyWrapper {
462+
var wrappedValue: Int { .zero }
463+
var projectedValue: Int { .max }
464+
}
465+
466+
// https://github.com/apple/swift/issues/59380
467+
// https://github.com/apple/swift/issues/59494
468+
469+
// Make sure the nonisolated attribute propagates to the synthesized projectedValue
470+
// variable as well.
471+
472+
@MainActor
473+
class HasNonIsolatedProperty {
474+
@SimplePropertyWrapper nonisolated var value
475+
476+
deinit {
477+
_ = value
478+
_ = $value // Ok
479+
}
480+
}
481+
482+
@propertyWrapper
483+
struct SimplePropertyWrapper2 {
484+
var wrappedValue: Int
485+
var projectedValue: SimplePropertyWrapper2 { self }
486+
}
487+
488+
@MainActor
489+
class HasNonIsolatedProperty2 {
490+
@SimplePropertyWrapper2 nonisolated var value = 0
491+
nonisolated init() {}
492+
}
460493

494+
let hasNonIsolatedProperty2 = HasNonIsolatedProperty2()
495+
496+
Task { @MainActor in
497+
hasNonIsolatedProperty2.value = 10
498+
_ = hasNonIsolatedProperty2.$value.wrappedValue
499+
}
500+
501+
Task.detached {
502+
hasNonIsolatedProperty2.value = 10
503+
_ = hasNonIsolatedProperty2.$value.wrappedValue // Ok
504+
}
461505

462506
// ----------------------------------------------------------------------
463507
// Unsafe global actors

0 commit comments

Comments
 (0)