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
+2-22Lines changed: 2 additions & 22 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(){} // 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'}}
142
140
}
143
141
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
-
157
142
func test(){
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}}
func isolated(){} // expected-note{{calls to instance method 'isolated()' from outside of its actor context are implicitly asynchronous}}
663
+
func isolated(){}
664
+
665
+
staticfunc staticIsolated(){ // expected-note{{calls to static method 'staticIsolated()' from outside of its actor context are implicitly asynchronous}}
666
+
_ =SomeClassWithInits.shared
667
+
}
658
668
659
669
func hasDetached(){
660
670
Task.runDetached{
@@ -668,8 +678,10 @@ class SomeClassWithInits {
668
678
}
669
679
}
670
680
671
-
func outsideSomeClassWithInits(){
672
-
_ =SomeClassWithInits() // okay, initializer is not isolated
681
+
func outsideSomeClassWithInits(){ // expected-note 3 {{add '@MainActor' to make global function 'outsideSomeClassWithInits()' part of global actor 'MainActor'}}
682
+
_ =SomeClassWithInits() // expected-error{{initializer 'init()' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
683
+
_ =SomeClassWithInits.shared // expected-error{{static property 'shared' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
684
+
SomeClassWithInits.staticIsolated() // expected-error{{static method 'staticIsolated()' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
Copy file name to clipboardExpand all lines: test/Concurrency/global_actor_inference.swift
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,30 @@ class C2: P2 {
68
68
}
69
69
}
70
70
71
+
structAllInP1:P1{
72
+
func method(){} // expected-note {{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
73
+
func other(){} // expected-note {{calls to instance method 'other()' from outside of its actor context are implicitly asynchronous}}
74
+
}
75
+
76
+
func testAllInP1(ap1:AllInP1){ // expected-note 2 {{add '@SomeGlobalActor' to make global function 'testAllInP1(ap1:)' part of global actor 'SomeGlobalActor'}}
77
+
ap1.method() // expected-error{{instance method 'method()' isolated to global actor 'SomeGlobalActor' can not be referenced from this synchronous context}}
78
+
ap1.other() // expected-error{{instance method 'other()' isolated to global actor 'SomeGlobalActor' can not be referenced from this synchronous context}}
79
+
}
80
+
81
+
structNotAllInP1{
82
+
func other(){}
83
+
}
84
+
85
+
extensionNotAllInP1:P1{
86
+
func method(){} // expected-note{{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
87
+
}
88
+
89
+
func testNotAllInP1(nap1:NotAllInP1){ // expected-note{{add '@SomeGlobalActor' to make global function 'testNotAllInP1(nap1:)' part of global actor 'SomeGlobalActor'}}
90
+
nap1.method() // expected-error{{instance method 'method()' isolated to global actor 'SomeGlobalActor' can not be referenced from this synchronous context}}
0 commit comments