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/Concurrency/actor_isolation_unsafe.swift
+28-5Lines changed: 28 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,31 @@ struct S4_P1: P1 {
33
33
@SomeGlobalActorfunc onMainActor(){} // expected-error{{instance method 'onMainActor()' isolated to global actor 'SomeGlobalActor' can not satisfy corresponding requirement from protocol 'P1' isolated to global actor 'MainActor'}}
34
34
}
35
35
36
+
@MainActor(unsafe)
37
+
protocolP2{
38
+
func f() // expected-note{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
39
+
@actorIndependentfunc g()
40
+
}
41
+
42
+
structS5_P2:P2{
43
+
func f(){} // expected-note{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
44
+
func g(){}
45
+
}
46
+
47
+
@actorIndependentfunc testP2(x:S5_P2, p2:P2){
48
+
p2.f() // expected-error{{instance method 'f()' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
49
+
p2.g() // OKAY
50
+
x.f() // expected-error{{'f()' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
overridefunc method(){ // expected-note{{overridden declaration is here}}
69
+
overridefunc method(){ // expected-note 2{{overridden declaration is here}}
45
70
globalSome() // okay
46
71
}
47
72
}
@@ -65,14 +90,12 @@ class C5: C1 {
65
90
66
91
classC6:C2{
67
92
// We didn't infer any actor isolation for C2.method().
68
-
@SomeGlobalActoroverridefunc method(){ // expected-error{{global actor 'SomeGlobalActor'-isolated instance method 'method()' has different actor isolation from non-actor-isolated overridden declaration}}
93
+
@SomeGlobalActoroverridefunc method(){ // expected-error{{global actor 'SomeGlobalActor'-isolated instance method 'method()' has different actor isolation from global actor 'MainActor'-isolated overridden declaration}}
69
94
}
70
95
}
71
96
72
97
classC7:C2{
73
-
// We didn't infer any actor isolation for C2.method(), but it's okay to be
74
-
// explicitly unsafe.
75
-
@SomeGlobalActor(unsafe)overridefunc method(){
98
+
@SomeGlobalActor(unsafe)overridefunc method(){ // expected-error{{global actor 'SomeGlobalActor'-isolated instance method 'method()' has different actor isolation from global actor 'MainActor'-isolated overridden declaration}}
76
99
globalMain() // expected-error{{global function 'globalMain()' isolated to global actor 'MainActor' can not be referenced from different global actor 'SomeGlobalActor'}}
0 commit comments