Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,6 @@ struct PrintOptions {
/// compilers that might parse the result.
bool PrintCompatibilityFeatureChecks = false;

/// Whether to print @_specialize attributes that have an availability
/// parameter.
bool PrintSpecializeAttributeWithAvailability = true;

/// Whether to always desugar array types from `[base_type]` to `Array<base_type>`
bool AlwaysDesugarArraySliceTypes = false;

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ BASELINE_LANGUAGE_FEATURE(BuiltinAllocVector, 0, "Builtin.allocVector")
BASELINE_LANGUAGE_FEATURE(BuiltinTaskRunInline, 0, "Builtin.taskRunInline")
BASELINE_LANGUAGE_FEATURE(BuiltinUnprotectedAddressOf, 0, "Builtin.unprotectedAddressOf")
BASELINE_LANGUAGE_FEATURE(NewCxxMethodSafetyHeuristics, 0, "Only import C++ methods that return pointers (projections) on owned types as unsafe")
SUPPRESSIBLE_LANGUAGE_FEATURE(SpecializeAttributeWithAvailability, 0, "@_specialize attribute with availability")
BASELINE_LANGUAGE_FEATURE(SpecializeAttributeWithAvailability, 0, "@_specialize attribute with availability")
BASELINE_LANGUAGE_FEATURE(BuiltinAssumeAlignment, 0, "Builtin.assumeAlignment")
BASELINE_LANGUAGE_FEATURE(BuiltinCreateTaskGroupWithFlags, 0, "Builtin.createTaskGroupWithFlags")
BASELINE_LANGUAGE_FEATURE(UnsafeInheritExecutor, 0, "@_unsafeInheritExecutor")
Expand Down
8 changes: 0 additions & 8 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3061,14 +3061,6 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
}
}

static void suppressingFeatureSpecializeAttributeWithAvailability(
PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> scope(
options.PrintSpecializeAttributeWithAvailability, false);
action();
}

static void suppressingFeatureIsolatedAny(PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);
Expand Down
6 changes: 0 additions & 6 deletions lib/AST/Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,12 +1465,6 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
if (Options.printPublicInterface() && !attr->getSPIGroups().empty())
return false;

// Don't print the _specialize attribute if we are asked to skip the ones
// with availability parameters.
if (!Options.PrintSpecializeAttributeWithAvailability &&
!attr->getAvailableAttrs().empty())
return false;

Printer << "@" << getAttrName() << "(";
auto exported = attr->isExported() ? "true" : "false";
auto kind = attr->isPartialSpecialization() ? "partial" : "full";
Expand Down
10 changes: 0 additions & 10 deletions lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ static bool usesTypeMatching(Decl *decl, llvm::function_ref<bool(Type)> fn) {
#define UNINTERESTING_FEATURE(FeatureName) \
static bool usesFeature##FeatureName(Decl *decl) { return false; }

static bool usesFeatureSpecializeAttributeWithAvailability(Decl *decl) {
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
for (auto specialize : func->getAttrs().getAttributes<SpecializeAttr>()) {
if (!specialize->getAvailableAttrs().empty())
return true;
}
}
return false;
}

// ----------------------------------------------------------------------------
// MARK: - Upcoming Features
// ----------------------------------------------------------------------------
Expand Down
16 changes: 0 additions & 16 deletions test/ModuleInterface/features.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@
// feature is old enough. The --implicit-check-not arguments to FileCheck above
// verify that those guards no longer pollute the emitted interface.

// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
// CHECK: public func specializeWithAvailability<T>(_ t: T)
// CHECK: #else
// CHECK: public func specializeWithAvailability<T>(_ t: T)
// CHECK: #endif
@_specialize(exported: true, availability: macOS 12, *; where T == Int)
public func specializeWithAvailability<T>(_ t: T) {
}

// CHECK: public actor MyActor
// CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor {
// CHECK-NEXT: get
Expand Down Expand Up @@ -135,12 +125,6 @@ public func asyncIsh(@_inheritActorContext operation: @Sendable @escaping () asy
@_unsafeInheritExecutor
public func unsafeInheritExecutor() async {}

// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
// CHECK: @_specialize{{.*}}
// CHECK: public func unsafeInheritExecutorAndSpecialize<T>(value: T) async
@_unsafeInheritExecutor
@_specialize(exported: true, availability: SwiftStdlib 5.1, *; where T == Int)
public func unsafeInheritExecutorAndSpecialize<T>(value: T) async {}

// CHECK: @_unavailableFromAsync(message: "Test") public func unavailableFromAsyncFunc()
@_unavailableFromAsync(message: "Test")
Expand Down
19 changes: 19 additions & 0 deletions test/ModuleInterface/specialize-attr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name Test
// R/UN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name Test -disable-experimental-parser-round-trip
// RUN: %FileCheck %s --implicit-check-not "\$SpecializeAttributeWithAvailability" < %t.swiftinterface

// CHECK: @_specialize(exported: false, kind: full, where T == Swift.Double)
// CHECK: public func specialize<T>(_ t: T)
@_specialize(exported: false, where T == Double)
public func specialize<T>(_ t: T) {}

// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
// CHECK: public func specializeWithAvailability<T>(_ t: T)
@_specialize(exported: true, availability: macOS 12, *; where T == Int)
public func specializeWithAvailability<T>(_ t: T) {}

// CHECK: @_specialize(exported: true, kind: full, availability: macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *; where T == Swift.Int)
// CHECK: public func specializeWithStdlibAvailability<T>(value: T) async
@_specialize(exported: true, availability: SwiftStdlib 5.1, *; where T == Int)
public func specializeWithStdlibAvailability<T>(value: T) async {}