Skip to content

[6.0][Concurrency] Fix disallowed override isolation to carry `@preconcurr… #75112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5274,7 +5274,12 @@ ActorIsolation ActorIsolationRequest::evaluate(
break;

case OverrideIsolationResult::Disallowed:
inferred = *overriddenIso;
if (overriddenValue->hasClangNode() &&
overriddenIso->isUnspecified()) {
inferred = overriddenIso->withPreconcurrency(true);
} else {
inferred = *overriddenIso;
}
break;
}
}
Expand Down
13 changes: 13 additions & 0 deletions test/ClangImporter/objc_isolation_complete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ class IsolatedSub: NXSender {
return mainActorState
}
}

@objc
@MainActor
class Test : NSObject {
static var shared: Test? // expected-note {{mutation of this static property is only permitted within the actor}}

override init() {
super.init()

Self.shared = self
// 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}}
}
}