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 @@ -5389,13 +5389,12 @@ getIsolationFromConformances(NominalTypeDecl *nominal) {
5389
5389
5390
5390
case ActorIsolation::GlobalActor:
5391
5391
// If we encountered an explicit globally isolated conformance, allow it
5392
- // to override the nonisolated isolation kind .
5392
+ // to override the _nonisolated_ isolation.
5393
5393
if (!foundIsolation ||
5394
- conformance->getSourceKind () == ConformanceEntryKind::Explicit) {
5395
- foundIsolation = {
5396
- protoIsolation,
5397
- IsolationSource (proto, IsolationSource::Conformance)
5398
- };
5394
+ (foundIsolation->isolation .isNonisolated () &&
5395
+ conformance->getSourceKind () == ConformanceEntryKind::Explicit)) {
5396
+ foundIsolation = {protoIsolation,
5397
+ IsolationSource (proto, IsolationSource::Conformance)};
5399
5398
continue ;
5400
5399
}
5401
5400
Original file line number Diff line number Diff line change 5
5
@MainActor
6
6
protocol GloballyIsolated { }
7
7
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
+
8
21
// expected-note@+1 {{class 'NonSendable' does not conform to the 'Sendable' protocol}}
9
22
class NonSendable { }
10
23
@@ -312,3 +325,25 @@ func rdar147965036() {
312
325
// expected-error@-2 {{'nonisolated' is not supported on a closure}}
313
326
}
314
327
}
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