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