Skip to content

Commit

Permalink
AST: Promote RetroactiveAttribute feature to baseline.
Browse files Browse the repository at this point in the history
  • Loading branch information
tshortli committed Jul 9, 2024
1 parent e7ae787 commit b71e73d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 37 deletions.
2 changes: 1 addition & 1 deletion include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ BASELINE_LANGUAGE_FEATURE(MoveOnlyResilientTypes, 390, "non-@frozen noncopyable
BASELINE_LANGUAGE_FEATURE(ParameterPacks, 393, "Value and type parameter packs")
BASELINE_LANGUAGE_FEATURE(LexicalLifetimes, 0, "@_eagerMove/@_noEagerMove/@_lexicalLifetimes annotations")
BASELINE_LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
SUPPRESSIBLE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
BASELINE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
BASELINE_LANGUAGE_FEATURE(ExtensionMacroAttr, 0, "@attached(extension)")
BASELINE_LANGUAGE_FEATURE(TypedThrows, 413, "Typed throws")
BASELINE_LANGUAGE_FEATURE(OptionalIsolatedParameters, 420, "Optional isolated parameters")
Expand Down
8 changes: 0 additions & 8 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3035,14 +3035,6 @@ static void suppressingFeatureSpecializeAttributeWithAvailability(
action();
}

static void suppressingFeatureRetroactiveAttribute(
PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<PrintOptions> originalOptions(options);
options.ExcludeAttrList.push_back(TypeAttrKind::Retroactive);
action();
}

static void suppressingFeatureIsolatedAny(PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);
Expand Down
10 changes: 0 additions & 10 deletions lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ static bool usesFeatureSpecializeAttributeWithAvailability(Decl *decl) {
return false;
}

static bool usesFeatureRetroactiveAttribute(Decl *decl) {
auto ext = dyn_cast<ExtensionDecl>(decl);
if (!ext)
return false;

return llvm::any_of(
ext->getInherited().getEntries(),
[](const InheritedEntry &entry) { return entry.isRetroactive(); });
}

static bool usesFeatureAssociatedTypeImplements(Decl *decl) {
return isa<TypeDecl>(decl) && decl->getAttrs().hasAttribute<ImplementsAttr>();
}
Expand Down
18 changes: 0 additions & 18 deletions test/ModuleInterface/retroactive-conformances.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,12 @@
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name Test
// RUN: %FileCheck %s < %t.swiftinterface

// CHECK: #if compiler(>=5.3) && $RetroactiveAttribute
// CHECK: extension Swift.Int : @retroactive Swift.Identifiable {
// CHECK: public var id: Swift.Int {
// CHECK: get
// CHECK: }
// CHECK: public typealias ID = Swift.Int
// CHECK: }
// CHECK: #else
// CHECK: extension Swift.Int : Swift.Identifiable {
// CHECK: public var id: Swift.Int {
// CHECK: get
// CHECK: }
// CHECK: public typealias ID = Swift.Int
// CHECK: }
// CHECK: #endif
extension Int: @retroactive Identifiable {
public var id: Int { self }
}

// CHECK: #if compiler(>=5.3) && $RetroactiveAttribute
// CHECK: extension Swift.String : @retroactive Swift.Identifiable {
// CHECK-NOT: #else
// CHECK: #endif
@_disallowFeatureSuppression(RetroactiveAttribute)
extension String: @retroactive Identifiable {
public var id: String { self }
}

0 comments on commit b71e73d

Please sign in to comment.