@@ -100,6 +100,7 @@ nonisolated struct S1: GloballyIsolated {
100
100
// MARK: - Protocols
101
101
102
102
nonisolated protocol Refined : GloballyIsolated { }
103
+ nonisolated protocol WhyNot { }
103
104
104
105
struct A : Refined {
105
106
var x : NonSendable
@@ -116,12 +117,30 @@ struct A: Refined {
116
117
117
118
@MainActor protocol ExplicitGlobalActor : Refined { }
118
119
119
- struct IsolatedStruct : ExplicitGlobalActor {
120
+ struct IsolatedA : ExplicitGlobalActor {
120
121
// expected-note@+2 {{main actor isolation inferred from conformance to protocol 'ExplicitGlobalActor'}}
121
122
// expected-note@+1 {{calls to instance method 'g()' from outside of its actor context are implicitly asynchronous}}
122
123
func g( ) { }
123
124
}
124
125
126
+ struct IsolatedB : Refined , ExplicitGlobalActor {
127
+ // expected-note@+2 {{calls to instance method 'h()' from outside of its actor context are implicitly asynchronous}}
128
+ // expected-note@+1 {{main actor isolation inferred from conformance to protocol 'ExplicitGlobalActor'}}
129
+ func h( ) { }
130
+ }
131
+
132
+ struct IsolatedC : WhyNot , GloballyIsolated {
133
+ // expected-note@+2 {{calls to instance method 'k()' from outside of its actor context are implicitly asynchronous}}
134
+ // expected-note@+1 {{main actor isolation inferred from conformance to protocol 'GloballyIsolated'}}
135
+ func k( ) { }
136
+ }
137
+
138
+ struct IsolatedCFlipped : GloballyIsolated , WhyNot {
139
+ // expected-note@+2 {{calls to instance method 'k2()' from outside of its actor context are implicitly asynchronous}}
140
+ // expected-note@+1 {{main actor isolation inferred from conformance to protocol 'GloballyIsolated'}}
141
+ func k2( ) { }
142
+ }
143
+
125
144
struct NonisolatedStruct {
126
145
func callF( ) {
127
146
return A ( ) . f ( ) // okay, 'A' is non-isolated.
@@ -130,7 +149,25 @@ struct NonisolatedStruct {
130
149
// expected-note@+1 {{add '@MainActor' to make instance method 'callG()' part of global actor 'MainActor'}}
131
150
func callG( ) {
132
151
// expected-error@+1{{call to main actor-isolated instance method 'g()' in a synchronous nonisolated context}}
133
- return IsolatedStruct ( ) . g ( )
152
+ return IsolatedA ( ) . g ( )
153
+ }
154
+
155
+ // expected-note@+1 {{add '@MainActor' to make instance method 'callH()' part of global actor 'MainActor'}}
156
+ func callH( ) {
157
+ // expected-error@+1 {{call to main actor-isolated instance method 'h()' in a synchronous nonisolated context}}
158
+ return IsolatedB ( ) . h ( )
159
+ }
160
+
161
+ // expected-note@+1 {{add '@MainActor' to make instance method 'callK()' part of global actor 'MainActor'}}
162
+ func callK( ) {
163
+ // expected-error@+1 {{call to main actor-isolated instance method 'k()' in a synchronous nonisolated context}}
164
+ return IsolatedC ( ) . k ( )
165
+ }
166
+
167
+ // expected-note@+1 {{add '@MainActor' to make instance method 'callK2()' part of global actor 'MainActor'}}
168
+ func callK2( ) {
169
+ // expected-error@+1 {{call to main actor-isolated instance method 'k2()' in a synchronous nonisolated context}}
170
+ return IsolatedCFlipped ( ) . k2 ( )
134
171
}
135
172
}
136
173
0 commit comments