Skip to content

Commit 997a252

Browse files
authored
Merge pull request #82585 from DougGregor/nonisolated-deinit-availability-6.2
"nonisolated deinit" does not have back-deployment constraints
2 parents b50dcb1 + 9412a9e commit 997a252

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7727,8 +7727,6 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
77277727
}
77287728
}
77297729

7730-
diagnoseIsolatedDeinitInValueTypes(attr);
7731-
77327730
if (auto VD = dyn_cast<ValueDecl>(D)) {
77337731
//'nonisolated(unsafe)' is meaningless for computed properties, functions etc.
77347732
auto var = dyn_cast<VarDecl>(VD);
@@ -7763,8 +7761,6 @@ void AttributeChecker::visitGlobalActorAttr(GlobalActorAttr *attr) {
77637761
return;
77647762
}
77657763

7766-
diagnoseIsolatedDeinitInValueTypes(attr);
7767-
77687764
(void)nominal->isGlobalActor();
77697765
}
77707766

test/Concurrency/deinit_isolation_in_value_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct CS: ~Copyable {
1919
}
2020

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

2525
struct ES: ~Copyable {
@@ -47,7 +47,7 @@ enum CE: ~Copyable {
4747
enum DE: ~Copyable {
4848
case dummy
4949
// expected-error@+1 {{deinitializers are not yet supported on noncopyable enums}}
50-
nonisolated deinit {} // expected-error {{only classes and actors can have isolated deinit}}
50+
nonisolated deinit {}
5151
}
5252

5353
enum EE: ~Copyable {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 5 %s -strict-concurrency=complete -target %target-swift-5.1-abi-triple
2+
3+
// REQUIRES: concurrency
4+
// REQUIRES: OS=macosx
5+
6+
class NotSendable {}
7+
8+
@MainActor class C {
9+
var x: Int = 0
10+
11+
nonisolated deinit {
12+
print(x)
13+
}
14+
}
15+
16+
// expected-note@+1{{add '@available' attribute to enclosing class}}
17+
@MainActor class C2 {
18+
var x: Int = 0
19+
20+
isolated deinit { // expected-error{{isolated deinit is only available in macOS 15.4.0 or newer}}
21+
print(x)
22+
}
23+
}

0 commit comments

Comments
 (0)