Skip to content

"nonisolated deinit" does not have back-deployment constraints #82585

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
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
4 changes: 0 additions & 4 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7727,8 +7727,6 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
}
}

diagnoseIsolatedDeinitInValueTypes(attr);

if (auto VD = dyn_cast<ValueDecl>(D)) {
//'nonisolated(unsafe)' is meaningless for computed properties, functions etc.
auto var = dyn_cast<VarDecl>(VD);
Expand Down Expand Up @@ -7763,8 +7761,6 @@ void AttributeChecker::visitGlobalActorAttr(GlobalActorAttr *attr) {
return;
}

diagnoseIsolatedDeinitInValueTypes(attr);

(void)nominal->isGlobalActor();
}

Expand Down
4 changes: 2 additions & 2 deletions test/Concurrency/deinit_isolation_in_value_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct CS: ~Copyable {
}

struct DS: ~Copyable {
nonisolated deinit {} // expected-error {{only classes and actors can have isolated deinit}}
nonisolated deinit {}
}

struct ES: ~Copyable {
Expand Down Expand Up @@ -47,7 +47,7 @@ enum CE: ~Copyable {
enum DE: ~Copyable {
case dummy
// expected-error@+1 {{deinitializers are not yet supported on noncopyable enums}}
nonisolated deinit {} // expected-error {{only classes and actors can have isolated deinit}}
nonisolated deinit {}
}

enum EE: ~Copyable {
Expand Down
23 changes: 23 additions & 0 deletions test/Concurrency/nonisolated_deinit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: %target-typecheck-verify-swift -swift-version 5 %s -strict-concurrency=complete -target %target-swift-5.1-abi-triple

// REQUIRES: concurrency
// REQUIRES: OS=macosx

class NotSendable {}

@MainActor class C {
var x: Int = 0

nonisolated deinit {
print(x)
}
}

// expected-note@+1{{add '@available' attribute to enclosing class}}
@MainActor class C2 {
var x: Int = 0

isolated deinit { // expected-error{{isolated deinit is only available in macOS 15.4.0 or newer}}
print(x)
}
}