File tree Expand file tree Collapse file tree 2 files changed +40
-6
lines changed Expand file tree Collapse file tree 2 files changed +40
-6
lines changed Original file line number Diff line number Diff line change @@ -5408,13 +5408,12 @@ getIsolationFromConformances(NominalTypeDecl *nominal) {
54085408
54095409 case ActorIsolation::GlobalActor:
54105410 // If we encountered an explicit globally isolated conformance, allow it
5411- // to override the nonisolated isolation kind .
5411+ // to override the _nonisolated_ isolation.
54125412 if (!foundIsolation ||
5413- conformance->getSourceKind () == ConformanceEntryKind::Explicit) {
5414- foundIsolation = {
5415- protoIsolation,
5416- IsolationSource (proto, IsolationSource::Conformance)
5417- };
5413+ (foundIsolation->isolation .isNonisolated () &&
5414+ conformance->getSourceKind () == ConformanceEntryKind::Explicit)) {
5415+ foundIsolation = {protoIsolation,
5416+ IsolationSource (proto, IsolationSource::Conformance)};
54185417 continue ;
54195418 }
54205419
Original file line number Diff line number Diff line change 55@MainActor
66protocol GloballyIsolated { }
77
8+ @globalActor
9+ actor Test {
10+ static let shared : Test = Test ( )
11+ }
12+
13+ @Test
14+ protocol TestIsolatedProto {
15+ }
16+
17+ @Test
18+ protocol RedeclaredIsolationProto : GloballyIsolated {
19+ }
20+
821// expected-note@+1 {{class 'NonSendable' does not conform to the 'Sendable' protocol}}
922class NonSendable { }
1023
@@ -312,3 +325,25 @@ func rdar147965036() {
312325 // expected-error@-2 {{'nonisolated' is not supported on a closure}}
313326 }
314327}
328+
329+ // Test that clash in isolation from protocols results in nonisolated conforming type
330+ func testProtocolIsolationClash( ) {
331+ struct A : GloballyIsolated , TestIsolatedProto {
332+ }
333+
334+ struct B : RedeclaredIsolationProto {
335+ }
336+
337+ struct C : GloballyIsolated , TestIsolatedProto , WhyNot {
338+ }
339+
340+ struct D : WhyNot , GloballyIsolated , TestIsolatedProto {
341+ }
342+
343+ nonisolated func test( ) {
344+ _ = A ( ) // Ok
345+ _ = B ( ) // Ok
346+ _ = C ( ) // Ok
347+ _ = D ( ) // Ok
348+ }
349+ }
You can’t perform that action at this time.
0 commit comments