File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -834,6 +834,13 @@ namespace {
834834 }
835835 }
836836
837+ // The children of #selector expressions are not evaluation, so we do not
838+ // need to do isolation checking there. This is convenient because such
839+ // expressions tend to violate restrictions on the use of instance
840+ // methods.
841+ if (isa<ObjCSelectorExpr>(expr))
842+ return { false , expr };
843+
837844 return { true , expr };
838845 }
839846
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
2+ // REQUIRES: concurrency
3+ // REQUIRES: objc_interop
4+
5+ import Foundation
6+
7+ func g( _ selector: Selector ) -> Int { }
8+
9+ actor class A {
10+ func selectors( ) {
11+ _ = #selector( type ( of: self ) . f) // expected-error{{argument of '#selector' refers to instance method 'f()' that is not exposed to Objective-C}}
12+ _ = #selector( type ( of: self ) . g) // expected-error{{argument of '#selector' refers to instance method 'g()' that is not exposed to Objective-C}}
13+ _ = #selector( type ( of: self ) . h)
14+ }
15+
16+ func keypaths( ) {
17+ _ = #keyPath( A . x) // expected-error{{argument of '#keyPath' refers to non-'@objc' property 'x'}}
18+ _ = #keyPath( A . y) // expected-error{{argument of '#keyPath' refers to non-'@objc' property 'y'}}
19+ _ = #keyPath( A . z)
20+ }
21+
22+ var x : Int = 0 // expected-note{{add '@objc' to expose this property to Objective-C}}
23+ @objc var y : Int = 0 // expected-note{{add '@objc' to expose this property to Objective-C}}
24+ // expected-error@-1{{actor-isolated property 'y' cannot be @objc}}
25+ @objc @actorIndependent ( unsafe) var z : Int = 0
26+
27+ func f( ) { } // expected-note{{add '@objc' to expose this instance method to Objective-C}}
28+ func g( ) { } // expected-note{{add '@objc' to expose this instance method to Objective-C}}
29+ @objc func h( ) async { }
30+ }
31+
32+
33+
You can’t perform that action at this time.
0 commit comments