Skip to content

Commit 49dcbb7

Browse files
committed
AST: Re-baseline BitwiseCopyable2 feature.
1 parent 6dd3e49 commit 49dcbb7

File tree

5 files changed

+8
-56
lines changed

5 files changed

+8
-56
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@ struct PrintOptions {
449449
/// Suppress printing of '~Proto' for suppressible, non-invertible protocols.
450450
bool SuppressConformanceSuppression = false;
451451

452-
/// Replace BitwiseCopyable with _BitwiseCopyable.
453-
bool SuppressBitwiseCopyable = false;
454-
455452
/// Suppress modify/read accessors.
456453
bool SuppressCoroutineAccessors = false;
457454

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ BASELINE_LANGUAGE_FEATURE(BitwiseCopyable, 426, "BitwiseCopyable protocol")
246246
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
247247
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics2, 427, "Noncopyable generics alias")
248248
BASELINE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
249-
SUPPRESSIBLE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
249+
BASELINE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
250250
BASELINE_LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
251251
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
252252
BASELINE_LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,13 +3247,6 @@ suppressingFeatureSendingArgsAndResults(PrintOptions &options,
32473247
action();
32483248
}
32493249

3250-
static void
3251-
suppressingFeatureBitwiseCopyable2(PrintOptions &options,
3252-
llvm::function_ref<void()> action) {
3253-
llvm::SaveAndRestore<bool> scope(options.SuppressBitwiseCopyable, true);
3254-
action();
3255-
}
3256-
32573250
static void
32583251
suppressingFeatureIsolatedDeinit(PrintOptions &options,
32593252
llvm::function_ref<void()> action) {
@@ -3604,28 +3597,17 @@ void PrintAST::visitOpaqueTypeDecl(OpaqueTypeDecl *decl) {
36043597

36053598
void PrintAST::visitTypeAliasDecl(TypeAliasDecl *decl) {
36063599
auto name = decl->getName();
3607-
bool suppressingBitwiseCopyable =
3608-
Options.SuppressBitwiseCopyable &&
3609-
decl->getModuleContext()->isStdlibModule() &&
3610-
(decl->getNameStr() == "_BitwiseCopyable");
3611-
if (suppressingBitwiseCopyable) {
3612-
name = decl->getASTContext().getIdentifier("BitwiseCopyable");
3613-
}
36143600
printDocumentationComment(decl);
36153601
printAttributes(decl);
36163602
printAccess(decl);
36173603
Printer.printIntroducerKeyword("typealias", Options, " ");
36183604
printContextIfNeeded(decl);
3619-
recordDeclLoc(decl,
3620-
[&]{
3621-
Printer.printName(name, getTypeMemberPrintNameContext(decl));
3622-
}, [&]{ // Signature
3623-
printGenericDeclGenericParams(decl);
3624-
});
3625-
if (suppressingBitwiseCopyable) {
3626-
Printer << " = Swift._BitwiseCopyable";
3627-
return;
3628-
}
3605+
recordDeclLoc(
3606+
decl,
3607+
[&] { Printer.printName(name, getTypeMemberPrintNameContext(decl)); },
3608+
[&] { // Signature
3609+
printGenericDeclGenericParams(decl);
3610+
});
36293611
bool ShouldPrint = true;
36303612
Type Ty = decl->getUnderlyingType();
36313613

@@ -3821,11 +3803,6 @@ void PrintAST::printPrimaryAssociatedTypes(ProtocolDecl *decl) {
38213803

38223804
void PrintAST::visitProtocolDecl(ProtocolDecl *decl) {
38233805
auto name = decl->getName();
3824-
if (Options.SuppressBitwiseCopyable &&
3825-
decl->getModuleContext()->isStdlibModule() &&
3826-
(decl->getNameStr() == "BitwiseCopyable")) {
3827-
name = decl->getASTContext().getIdentifier("_BitwiseCopyable");
3828-
}
38293806
printDocumentationComment(decl);
38303807
printAttributes(decl);
38313808
printAccess(decl);

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -361,19 +361,6 @@ UNINTERESTING_FEATURE(ClosureIsolation)
361361
UNINTERESTING_FEATURE(Extern)
362362
UNINTERESTING_FEATURE(ConsumeSelfInDeinit)
363363

364-
static bool usesFeatureBitwiseCopyable2(Decl *decl) {
365-
if (!decl->getModuleContext()->isStdlibModule()) {
366-
return false;
367-
}
368-
if (auto *proto = dyn_cast<ProtocolDecl>(decl)) {
369-
return proto->getNameStr() == "BitwiseCopyable";
370-
}
371-
if (auto *typealias = dyn_cast<TypeAliasDecl>(decl)) {
372-
return typealias->getNameStr() == "_BitwiseCopyable";
373-
}
374-
return false;
375-
}
376-
377364
static bool usesFeatureIsolatedAny(Decl *decl) {
378365
return usesTypeMatching(decl, [](Type type) {
379366
if (auto fnType = type->getAs<AnyFunctionType>()) {

test/ModuleInterface/bitwise_copyable_stdlib.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
// RUN: %FileCheck %s < %t.swiftinterface
44
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -parse-stdlib -module-name Swift
55

6-
// CHECK: #if compiler(>=5.3) && $BitwiseCopyable2
7-
// CHECK-NEXT: public protocol BitwiseCopyable {
6+
// CHECK: public protocol BitwiseCopyable {
87
// CHECK-NEXT: }
9-
// CHECK-NEXT: #else
10-
// CHECK-NEXT: public protocol _BitwiseCopyable {
11-
// CHECK-NEXT: }
12-
// CHECK-NEXT: #endif
138

14-
// CHECK: #if compiler(>=5.3) && $BitwiseCopyable2
159
// CHECK-NEXT: public typealias _BitwiseCopyable = Swift.BitwiseCopyable
16-
// CHECK-NEXT: #else
17-
// CHECK-NEXT: public typealias BitwiseCopyable = Swift._BitwiseCopyable
18-
// CHECK-NEXT: #endif
1910
public protocol BitwiseCopyable {}
2011
public typealias _BitwiseCopyable = BitwiseCopyable
2112

0 commit comments

Comments
 (0)