File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -5093,7 +5093,8 @@ bool swift::contextRequiresStrictConcurrencyChecking(
5093
5093
// features.
5094
5094
if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
5095
5095
auto *nominal = extension->getExtendedNominal ();
5096
- if (nominal && hasExplicitIsolationAttribute (nominal))
5096
+ if (nominal && hasExplicitIsolationAttribute (nominal) &&
5097
+ !getActorIsolation (nominal).preconcurrency ())
5097
5098
return true ;
5098
5099
}
5099
5100
Original file line number Diff line number Diff line change @@ -219,3 +219,29 @@ nonisolated func blah() {
219
219
InferMainActorPreconcurrency . predatesConcurrency ( )
220
220
// expected-warning@-1 {{call to main actor-isolated static method 'predatesConcurrency()' in a synchronous nonisolated context}}
221
221
}
222
+
223
+ protocol NotIsolated {
224
+ func requirement( )
225
+ // expected-complete-tns-note@-1 {{mark the protocol requirement 'requirement()' 'async' to allow actor-isolated conformances}}
226
+ }
227
+
228
+ extension MainActorPreconcurrency : NotIsolated {
229
+ func requirement( ) { }
230
+ // expected-complete-tns-warning@-1 {{main actor-isolated instance method 'requirement()' cannot be used to satisfy nonisolated protocol requirement}}
231
+ // expected-complete-tns-note@-2 {{add 'nonisolated' to 'requirement()' to make this instance method not isolated to the actor}}
232
+ // expected-complete-tns-note@-3 {{calls to instance method 'requirement()' from outside of its actor context are implicitly asynchronous}}
233
+
234
+
235
+ class Nested {
236
+ weak var c : MainActorPreconcurrency ?
237
+
238
+ func test( ) {
239
+ // expected-complete-tns-note@-1 {{add '@MainActor' to make instance method 'test()' part of global actor 'MainActor'}}
240
+
241
+ if let c {
242
+ c. requirement ( )
243
+ // expected-complete-tns-warning@-1 {{call to main actor-isolated instance method 'requirement()' in a synchronous nonisolated context}}
244
+ }
245
+ }
246
+ }
247
+ }
You can’t perform that action at this time.
0 commit comments