Skip to content

Commit 14d8e02

Browse files
authored
Merge pull request swiftlang#75112 from xedin/rdar-130776220-6.0
[6.0][Concurrency] Fix disallowed override isolation to carry `@preconcurr…
2 parents ee010a9 + a5e6d31 commit 14d8e02

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5280,7 +5280,12 @@ ActorIsolation ActorIsolationRequest::evaluate(
52805280
break;
52815281

52825282
case OverrideIsolationResult::Disallowed:
5283-
inferred = *overriddenIso;
5283+
if (overriddenValue->hasClangNode() &&
5284+
overriddenIso->isUnspecified()) {
5285+
inferred = overriddenIso->withPreconcurrency(true);
5286+
} else {
5287+
inferred = *overriddenIso;
5288+
}
52845289
break;
52855290
}
52865291
}

test/ClangImporter/objc_isolation_complete.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,16 @@ class IsolatedSub: NXSender {
3131
return mainActorState
3232
}
3333
}
34+
35+
@objc
36+
@MainActor
37+
class Test : NSObject {
38+
static var shared: Test? // expected-note {{mutation of this static property is only permitted within the actor}}
39+
40+
override init() {
41+
super.init()
42+
43+
Self.shared = self
44+
// expected-warning@-1 {{main actor-isolated static property 'shared' can not be mutated from a nonisolated context; this is an error in the Swift 6 language mode}}
45+
}
46+
}

0 commit comments

Comments
 (0)