You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/ClangImporter/objc_async.swift
+22-2Lines changed: 22 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
import Foundation
6
6
import ObjCConcurrency
7
7
8
-
@MainActorfunc onlyOnMainActor(){}
8
+
@MainActorfunc onlyOnMainActor(){} // expected-note{{calls to global function 'onlyOnMainActor()' from outside of its actor context are implicitly asynchronous}}
onButtonPress() // expected-error{{instance method 'onButtonPress()' isolated to global actor 'MainActor' can not be referenced from different global actor 'SomeGlobalActor'}}
140
142
}
141
143
144
+
func test(){ // expected-note{{add '@MainActor' to make instance method 'test()' part of global actor 'MainActor'}}
145
+
onButtonPress() // okay, onButtonPress is @MainActor(unsafe)
146
+
unsafelyOnSomeGlobal() // okay, we haven't opted into anything
147
+
onlyOnMainActor() // expected-error{{global function 'onlyOnMainActor()' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
148
+
}
149
+
}
150
+
151
+
classMyOtherButton:NXButton{
152
+
overridefunc onButtonPress(){ // expected-note{{calls to instance method 'onButtonPress()' from outside of its actor context are implicitly asynchronous}}
153
+
onlyOnMainActor() // yes, we're on the main actor
154
+
unsafelyOnSomeGlobal() // okay, we haven't opted into any actual checking
155
+
}
156
+
142
157
func test(){
143
-
onButtonPress() // okay
158
+
onButtonPress() // okay, it's @MainActor(unsafe)
159
+
}
160
+
161
+
@SomeGlobalActorfunc testOther(){
162
+
onButtonPress() // expected-error{{instance method 'onButtonPress()' isolated to global actor 'MainActor' can not be referenced from different global actor 'SomeGlobalActor' in a synchronous context}}
0 commit comments