Skip to content

Commit 3415189

Browse files
committed
[concurrency] Change execution to override inferred global actor isolation to match nonisolated.
Specifically, we were attempting to diagnose cases like the following: ```swift @mainactor protocol P { func foo() async } struct S : P { @execution(concurrent) func foo() async {} } ``` This was just an attempt to be more conservative. After some conversations, it came up that nonisolated does not work that way... that is the compiler will accept the following and just hop in the protocol witness thunk: ```swift @mainactor protocol P { func foo() async } struct S : P { nonisolated func foo() async {} } ```
1 parent 527616d commit 3415189

File tree

2 files changed

+0
-15
lines changed

2 files changed

+0
-15
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
306306
}
307307
}
308308

309-
// We need isolation check here because global actor isolation
310-
// could be inferred.
311-
312-
auto isolation = getActorIsolation(F);
313-
if (isolation.isGlobalActor()) {
314-
diagnoseAndRemoveAttr(
315-
attr,
316-
diag::attr_execution_concurrent_incompatible_with_global_actor, F,
317-
isolation.getGlobalActor());
318-
return;
319-
}
320-
321309
break;
322310
}
323311

test/attr/attr_execution.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ struct TestAttributeCollisions {
5151
// expected-error@-1 {{cannot use '@execution(concurrent)' on instance method 'testIsolationAny(arg:)' because it has a dynamically isolated parameter: 'arg'}}
5252

5353
@MainActor @execution(concurrent) func testGlobalActor() async {}
54-
// expected-error@-1 {{cannot use '@execution(concurrent)' on instance method 'testGlobalActor()' isolated to global actor 'MainActor'}}
5554

5655
@execution(concurrent) @Sendable func test(_: @Sendable () -> Void, _: sending Int) async {} // Ok
5756
}
@@ -63,11 +62,9 @@ protocol P {
6362

6463
struct InfersMainActor : P {
6564
@execution(concurrent) func test() async {}
66-
// expected-error@-1 {{cannot use '@execution(concurrent)' on instance method 'test()' isolated to global actor 'MainActor'}}
6765
}
6866

6967
@MainActor
7068
struct IsolatedType {
7169
@execution(concurrent) func test() async {}
72-
// expected-error@-1 {{cannot use '@execution(concurrent)' on instance method 'test()' isolated to global actor 'MainActor'}}
7370
}

0 commit comments

Comments
 (0)