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
[Actor inference] Infer global actors on a type based on conformances.
If a protocol is stated to be part of a global actor, infer that a type
that conforms to a protocol in its original definition is also part of
that global actor.
Addresses rdar://75992299.
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