File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -626,13 +626,35 @@ actor Rain {
626626
627627@available ( SwiftStdlib 5 . 5 , * )
628628actor 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}
You can’t perform that action at this time.
0 commit comments