Skip to content

Commit 088a72c

Browse files
committed
beef up the test
1 parent 1343f6b commit 088a72c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/Concurrency/flow_isolation.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,35 @@ actor Rain {
626626

627627
@available(SwiftStdlib 5.5, *)
628628
actor OhBrother {
629-
private var giver: () -> Int?
629+
private var giver: (OhBrother) -> Int
630+
private var whatever: Int = 0
630631

631632
static var DefaultResult: Int { 10 }
632633

633634
init() {
634635
// expected-note@+2 {{after this closure involving 'self', only non-isolated properties of 'self' can be accessed from this init}}
635636
// expected-warning@+1 {{cannot access property 'giver' here in non-isolated initializer; this is an error in Swift 6}}
636-
self.giver = { Self.DefaultResult }
637+
self.giver = { (x: OhBrother) -> Int in Self.DefaultResult }
638+
}
639+
640+
init(v2: Void) {
641+
giver = { (x: OhBrother) -> Int in 0 }
642+
643+
// make sure we don't call this a closure, which is the more common situation.
644+
645+
_ = giver(self) // expected-note {{after a call involving 'self', only non-isolated properties of 'self' can be accessed from this init}}
646+
647+
whatever = 1 // expected-warning {{cannot access property 'whatever' here in non-isolated initializer; this is an error in Swift 6}}
648+
}
649+
650+
init(v3: Void) {
651+
let blah = { (x: OhBrother) -> Int in 0 }
652+
giver = blah
653+
654+
// TODO: would be nice if we didn't say "after this closure" since it's not a capture, but a call.
655+
656+
_ = blah(self) // expected-note {{after this closure involving 'self', only non-isolated properties of 'self' can be accessed from this init}}
657+
658+
whatever = 2 // expected-warning {{cannot access property 'whatever' here in non-isolated initializer; this is an error in Swift 6}}
637659
}
638660
}

0 commit comments

Comments
 (0)