Skip to content

Commit a6bc0e6

Browse files
committed
temporary -experimental flag for IsolatedDeinit
1 parent 7d1ce78 commit a6bc0e6

14 files changed

+38
-94
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5912,14 +5912,16 @@ ERROR(async_named_decl_must_be_available_from_async,none,
59125912
ERROR(async_unavailable_decl,none,
59135913
"%kindbase0 is unavailable from asynchronous contexts%select{|; %1}1",
59145914
(const ValueDecl *, StringRef))
5915-
5916-
5915+
59175916
ERROR(isolated_deinit_no_isolation,none,
59185917
"deinit is marked isolated, but containing class %0 is not isolated to an actor",
59195918
(DeclName))
59205919
ERROR(isolated_deinit_on_value_type,none,
59215920
"only classes and actors can have isolated deinit",
59225921
())
5922+
ERROR(isolated_deinit_experimental,none,
5923+
"'isolated' deinit requires frontend flag -enable-experimental-feature IsolatedDeinit "
5924+
"to enable the usage of this language feature", ())
59235925

59245926
//------------------------------------------------------------------------------
59255927
// MARK: String Processing

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
111111
}
112112

113113
void diagnoseIsolatedDeinitInValueTypes(DeclAttribute *attr) {
114+
auto &C = D->getASTContext();
115+
114116
if (isa<DestructorDecl>(D)) {
117+
if (!C.LangOpts.hasFeature(Feature::IsolatedDeinit)) {
118+
diagnoseAndRemoveAttr(attr, diag::isolated_deinit_experimental);
119+
return;
120+
}
121+
115122
if (auto nominal = dyn_cast<NominalTypeDecl>(D->getDeclContext())) {
116123
if (!isa<ClassDecl>(nominal)) {
117124
// only classes and actors can have isolated deinit.

test/Concurrency/Runtime/actor_deinit_escaping_self.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library)
1+
// RUN: %target-run-simple-swift( -enable-experimental-feature IsolatedDeinit -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library)
22

33
// REQUIRES: executable_test
44
// REQUIRES: libdispatch

test/Concurrency/Runtime/actor_recursive_deinit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -parse-stdlib -parse-as-library) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-enable-experimental-feature IsolatedDeinit -Xfrontend -disable-availability-checking -parse-stdlib -parse-as-library) | %FileCheck %s
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency

test/Concurrency/Runtime/async_task_locals_isolated_deinit.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -plugin-path %swift-plugin-dir -Xfrontend -disable-availability-checking -parse-stdlib %import-libdispatch %s -o %t/a.out
2+
// RUN: %target-build-swift -plugin-path %swift-plugin-dir -enable-experimental-feature IsolatedDeinit -Xfrontend -disable-availability-checking -parse-stdlib %import-libdispatch %s -o %t/a.out
33
// RUN: %target-codesign %t/a.out
44
// RUN: %env-SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE=swift6 %target-run %t/a.out
55

@@ -9,6 +9,8 @@
99
// REQUIRES: concurrency_runtime
1010
// UNSUPPORTED: back_deployment_runtime
1111

12+
// REQUIRES: gh76538
13+
1214
import Swift
1315
import _Concurrency
1416
import Dispatch
@@ -131,6 +133,7 @@ if #available(SwiftStdlib 5.1, *) {
131133
let group = DispatchGroup()
132134
group.enter(1)
133135
Task {
136+
// FIXME: isolated deinit should be clearing task locals
134137
await TL.$number.withValue(42) {
135138
await AnotherActor.shared.performTesting {
136139
_ = ClassNoOp(expectedNumber: 42, group: group)
@@ -155,6 +158,7 @@ if #available(SwiftStdlib 5.1, *) {
155158
let group = DispatchGroup()
156159
group.enter(1)
157160
Task {
161+
// FIXME: isolated deinit should be clearing task locals
158162
TL.$number.withValue(99) {
159163
// Despite last release happening not on the actor itself,
160164
// this is still a fast path due to optimisation for deallocating actors.

test/Concurrency/Runtime/isolated_deinit_main_sync.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-enable-experimental-feature IsolatedDeinit -Xfrontend -disable-availability-checking) | %FileCheck %s
22

33
var isDead: Bool = false
44

test/Concurrency/deinit_isolation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -emit-silgen -verify %s
2-
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck %s
3-
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck -check-prefix=CHECK-SYMB %s
1+
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -enable-experimental-feature IsolatedDeinit -emit-silgen -verify %s
2+
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -enable-experimental-feature IsolatedDeinit -emit-silgen -DSILGEN %s | %FileCheck %s
3+
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -enable-experimental-feature IsolatedDeinit -emit-silgen -DSILGEN %s | %FileCheck -check-prefix=CHECK-SYMB %s
44

55
// REQUIRES: concurrency
66

test/Concurrency/deinit_isolation_import/test.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
// RUN: cp -R $INPUT_DIR/Alpha.framework %t/Frameworks/
44
// RUN: %empty-directory(%t/Frameworks/Alpha.framework/Modules/Alpha.swiftmodule)
55
// RUN: %empty-directory(%t/Frameworks/Alpha.framework/Headers/)
6-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -parse-as-library -module-name Alpha \
6+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -parse-as-library -module-name Alpha \
77
// RUN: -emit-module -o %t/Frameworks/Alpha.framework/Modules/Alpha.swiftmodule/%module-target-triple.swiftmodule \
88
// RUN: -enable-objc-interop -disable-objc-attr-requires-foundation-module \
99
// RUN: -emit-objc-header -emit-objc-header-path %t/Frameworks/Alpha.framework/Headers/Alpha-Swift.h $INPUT_DIR/Alpha.swift
1010
// RUN: cp -R $INPUT_DIR/Beta.framework %t/Frameworks/
1111
// RUN: %empty-directory(%t/Frameworks/Beta.framework/Headers/)
1212
// RUN: cp $INPUT_DIR/Beta.h %t/Frameworks/Beta.framework/Headers/Beta.h
13-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -disable-availability-checking -typecheck -verify %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks
14-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks | %FileCheck %s
15-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks | %FileCheck -check-prefix=CHECK-SYMB %s
13+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -typecheck -verify %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks
14+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks | %FileCheck %s
15+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks | %FileCheck -check-prefix=CHECK-SYMB %s
1616

1717
// REQUIRES: concurrency
1818
// REQUIRES: objc_interop

test/Concurrency/deinit_isolation_in_value_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -disable-availability-checking -parse-as-library -emit-silgen -verify %s
1+
// RUN: %target-swift-frontend -disable-availability-checking -enable-experimental-feature IsolatedDeinit -parse-as-library -emit-silgen -verify %s
22

33
@globalActor final actor FirstActor {
44
static let shared = FirstActor()

test/Concurrency/deinit_isolation_objc.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -verify %s
2-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck %s
3-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck -check-prefix=CHECK-SYMB %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -verify %s
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck %s
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s | %FileCheck -check-prefix=CHECK-SYMB %s
44

55
// REQUIRES: concurrency
66
// REQUIRES: objc_interop

0 commit comments

Comments
 (0)