Skip to content

[Concurrency] unguard nonisolated(unsafe) attribute from GlobalConcurrency experimental feature #70453

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
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
1 change: 0 additions & 1 deletion lib/ASTGen/Sources/ASTGen/SourceFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ extension Parser.ExperimentalFeatures {
mapFeature(.TypedThrows, to: .typedThrows)
mapFeature(.DoExpressions, to: .doExpressions)
mapFeature(.NonEscapableTypes, to: .nonEscapableTypes)
mapFeature(.GlobalConcurrency, to: .globalConcurrency)
}
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5579,8 +5579,7 @@ bool Parser::isStartOfSwiftDecl(bool allowPoundIfAttributes,
}

// If this is 'nonisolated', check to see if it is valid.
if (Context.LangOpts.hasFeature(Feature::GlobalConcurrency) &&
Tok.isContextualKeyword("nonisolated") && Tok2.is(tok::l_paren) &&
if (Tok.isContextualKeyword("nonisolated") && Tok2.is(tok::l_paren) &&
isParenthesizedNonisolated(*this)) {
BacktrackingScope backtrack(*this);
consumeToken(tok::identifier);
Expand Down
7 changes: 2 additions & 5 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6831,14 +6831,11 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
auto dc = D->getDeclContext();

if (auto var = dyn_cast<VarDecl>(D)) {
const bool isUnsafe =
attr->isUnsafe() && Ctx.LangOpts.hasFeature(Feature::GlobalConcurrency);

// stored properties have limitations as to when they can be nonisolated.
if (var->hasStorage()) {
// 'nonisolated' can not be applied to mutable stored properties unless
// qualified as 'unsafe'.
if (var->supportsMutation() && !isUnsafe) {
if (var->supportsMutation() && !attr->isUnsafe()) {
diagnoseAndRemoveAttr(attr, diag::nonisolated_mutable_storage);
return;
}
Expand Down Expand Up @@ -6883,7 +6880,7 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {

// nonisolated can not be applied to local properties unless qualified as
// 'unsafe'.
if (dc->isLocalContext() && !isUnsafe) {
if (dc->isLocalContext() && !attr->isUnsafe()) {
diagnoseAndRemoveAttr(attr, diag::nonisolated_local_var);
return;
}
Expand Down
6 changes: 2 additions & 4 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2834,8 +2834,7 @@ namespace {
return false;

if (auto attr = value->getAttrs().getAttribute<NonisolatedAttr>();
ctx.LangOpts.hasFeature(Feature::GlobalConcurrency) && attr &&
attr->isUnsafe()) {
attr && attr->isUnsafe()) {
return false;
}

Expand Down Expand Up @@ -3306,8 +3305,7 @@ namespace {
}

if (auto attr = var->getAttrs().getAttribute<NonisolatedAttr>();
ctx.LangOpts.hasFeature(Feature::GlobalConcurrency) && attr &&
attr->isUnsafe()) {
attr && attr->isUnsafe()) {
return false;
}

Expand Down