Skip to content

Commit a37ce9a

Browse files
committed
AST: Re-baseline IsolatedDeinit feature.
1 parent 71a5d9b commit a37ce9a

File tree

5 files changed

+3
-64
lines changed

5 files changed

+3
-64
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,6 @@ struct PrintOptions {
400400
/// Whether to print the internal layout name instead of AnyObject, etc.
401401
bool PrintInternalLayoutName = false;
402402

403-
/// Suppress emitting isolated or async deinit, and emit open containing class
404-
/// as public
405-
bool SuppressIsolatedDeinit = false;
406-
407403
/// Suppress @_lifetime attribute and emit @lifetime instead.
408404
bool SuppressLifetimes = false;
409405

include/swift/Basic/Features.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ LANGUAGE_FEATURE(BuiltinVectorsExternC, 0, "Extern C support for Builtin vector
271271
LANGUAGE_FEATURE(AddressOfProperty, 0, "Builtin.unprotectedAddressOf properties")
272272
LANGUAGE_FEATURE(NonescapableAccessorOnTrivial, 0, "Support UnsafeMutablePointer.mutableSpan")
273273
BASELINE_LANGUAGE_FEATURE(LayoutPrespecialization, 0, "Layout pre-specialization")
274+
BASELINE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
274275

275276
// Swift 6
276277
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -491,9 +492,6 @@ EXPERIMENTAL_FEATURE(SuppressCXXForeignReferenceTypeInitializers, true)
491492
/// or SWIFT_RETURNS_UNRETAINED.
492493
EXPERIMENTAL_FEATURE(WarnUnannotatedReturnOfCxxFrt, true)
493494

494-
// Isolated deinit
495-
SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
496-
497495
/// modify/read single-yield coroutines
498496
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CoroutineAccessors, true)
499497

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -887,14 +887,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
887887
return;
888888
if (D->getDeclContext()->isLocalContext())
889889
return;
890-
891-
if (Options.SuppressIsolatedDeinit &&
892-
D->getFormalAccess() == AccessLevel::Open &&
893-
usesFeatureIsolatedDeinit(D)) {
894-
printAccess(AccessLevel::Public);
895-
} else {
896-
printAccess(D->getFormalAccess());
897-
}
890+
891+
printAccess(D->getFormalAccess());
898892
bool shouldSkipSetterAccess =
899893
llvm::is_contained(Options.ExcludeAttrList, DeclAttrKind::SetterAccess);
900894

@@ -1423,14 +1417,6 @@ void PrintAST::printAttributes(const Decl *D) {
14231417
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Consuming);
14241418
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Borrowing);
14251419
}
1426-
1427-
if (isa<DestructorDecl>(D) && Options.SuppressIsolatedDeinit) {
1428-
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Nonisolated);
1429-
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Isolated);
1430-
if (auto globalActor = D->getGlobalActorAttr()) {
1431-
scope.Options.ExcludeCustomAttrList.push_back(globalActor->first);
1432-
}
1433-
}
14341420

14351421
attrs.print(Printer, Options, D);
14361422
}
@@ -3241,13 +3227,6 @@ suppressingFeatureSendingArgsAndResults(PrintOptions &options,
32413227
action();
32423228
}
32433229

3244-
static void
3245-
suppressingFeatureIsolatedDeinit(PrintOptions &options,
3246-
llvm::function_ref<void()> action) {
3247-
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedDeinit, true);
3248-
action();
3249-
}
3250-
32513230
static void
32523231
suppressingFeatureLifetimes(PrintOptions &options,
32533232
llvm::function_ref<void()> action) {

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -383,23 +383,6 @@ UNINTERESTING_FEATURE(WarnUnannotatedReturnOfCxxFrt)
383383
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
384384
UNINTERESTING_FEATURE(AllowRuntimeSymbolDeclarations)
385385

386-
bool swift::usesFeatureIsolatedDeinit(const Decl *decl) {
387-
if (auto cd = dyn_cast<ClassDecl>(decl)) {
388-
return cd->getFormalAccess() == AccessLevel::Open &&
389-
usesFeatureIsolatedDeinit(cd->getDestructor());
390-
} else if (auto dd = dyn_cast<DestructorDecl>(decl)) {
391-
if (dd->hasExplicitIsolationAttribute()) {
392-
return true;
393-
}
394-
if (auto superDD = dd->getSuperDeinit()) {
395-
return usesFeatureIsolatedDeinit(superDD);
396-
}
397-
return false;
398-
} else {
399-
return false;
400-
}
401-
}
402-
403386
static bool usesFeatureCoroutineAccessors(Decl *decl) {
404387
auto accessorDeclUsesFeatureCoroutineAccessors = [](AccessorDecl *accessor) {
405388
return requiresFeatureCoroutineAccessors(accessor->getAccessorKind());

test/ModuleInterface/isolated-deinit-compatibility.swift renamed to test/ModuleInterface/isolated-deinit.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,32 @@ public class SyncClassDefaultPublic {
2626
deinit {}
2727
}
2828

29-
// CHECK: #if {{.*}}$IsolatedDeinit
3029
// CHECK-NOT: #
3130
// CHECK: open class SyncClassGlobalActorOpen {
3231
// CHECK-NOT: #
3332
// CHECK: {{(@objc )?}}@_Concurrency.MainActor deinit
3433
// CHECK-NOT: #
3534
// CHECK: }
36-
// CHECK: #endif
3735
open class SyncClassGlobalActorOpen {
3836
@MainActor deinit {}
3937
}
4038

4139
// CHECK-NOT: #
4240
// CHECK: public class SyncClassGlobalActorPublic {
4341
// CHECK-NOT: #
44-
// CHECK: #if {{.*}}$IsolatedDeinit
4542
// CHECK-NOT: #
4643
// CHECK: {{(@objc )?}}@_Concurrency.MainActor deinit
4744
// CHECK: }
4845
public class SyncClassGlobalActorPublic {
4946
@MainActor deinit {}
5047
}
5148

52-
// CHECK: #if {{.*}}$IsolatedDeinit
5349
// CHECK-NOT: #
5450
// CHECK: @_Concurrency.MainActor open class SyncClassIsolatedOpen {
5551
// CHECK-NOT: #
5652
// CHECK: {{(@objc )?}}isolated deinit
5753
// CHECK-NOT: #
5854
// CHECK: }
59-
// CHECK: #endif
6055
@MainActor
6156
open class SyncClassIsolatedOpen {
6257
isolated deinit {}
@@ -65,23 +60,19 @@ open class SyncClassIsolatedOpen {
6560
// CHECK-NOT: #
6661
// CHECK: @_Concurrency.MainActor public class SyncClassIsolatedPublic {
6762
// CHECK-NOT: #
68-
// CHECK: #if {{.*}}$IsolatedDeinit
69-
// CHECK-NOT: #
7063
// CHECK: {{(@objc )?}}isolated deinit
7164
// CHECK: }
7265
@MainActor
7366
public class SyncClassIsolatedPublic {
7467
isolated deinit {}
7568
}
7669

77-
// CHECK: #if {{.*}}$IsolatedDeinit
7870
// CHECK-NOT: #
7971
// CHECK: @_Concurrency.MainActor open class SyncClassNonisolatedOpen {
8072
// CHECK-NOT: #
8173
// CHECK: {{(@objc )?}}nonisolated deinit
8274
// CHECK-NOT: #
8375
// CHECK: }
84-
// CHECK: #endif
8576
@MainActor
8677
open class SyncClassNonisolatedOpen {
8778
nonisolated deinit {}
@@ -90,8 +81,6 @@ open class SyncClassNonisolatedOpen {
9081
// CHECK-NOT: #
9182
// CHECK: @_Concurrency.MainActor public class SyncClassNonisolatedPublic {
9283
// CHECK-NOT: #
93-
// CHECK: #if {{.*}}$IsolatedDeinit
94-
// CHECK-NOT: #
9584
// CHECK: {{(@objc )?}}nonisolated deinit
9685
// CHECK: }
9786
@MainActor
@@ -114,8 +103,6 @@ public actor SyncActorDefaultPublic {
114103
// CHECK-NOT: #
115104
// CHECK: public actor SyncActorGlobalActorPublic {
116105
// CHECK-NOT: #
117-
// CHECK: #if {{.*}}$IsolatedDeinit
118-
// CHECK-NOT: #
119106
// CHECK: {{(@objc )?}}@_Concurrency.MainActor deinit
120107
// CHECK: }
121108
public actor SyncActorGlobalActorPublic {
@@ -125,8 +112,6 @@ public actor SyncActorGlobalActorPublic {
125112
// CHECK-NOT: #
126113
// CHECK: public actor SyncActorIsolatedPublic {
127114
// CHECK-NOT: #
128-
// CHECK: #if {{.*}}$IsolatedDeinit
129-
// CHECK-NOT: #
130115
// CHECK: {{(@objc )?}}isolated deinit
131116
// CHECK: }
132117
public actor SyncActorIsolatedPublic {
@@ -136,8 +121,6 @@ public actor SyncActorIsolatedPublic {
136121
// CHECK-NOT: #
137122
// CHECK: public actor SyncActorNonisolatedPublic {
138123
// CHECK-NOT: #
139-
// CHECK: #if {{.*}}$IsolatedDeinit
140-
// CHECK-NOT: #
141124
// CHECK: {{(@objc )?}}nonisolated deinit
142125
// CHECK: }
143126
public actor SyncActorNonisolatedPublic {

0 commit comments

Comments
 (0)