mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Re-baseline IsolatedAny feature.
This commit is contained in:
@@ -437,9 +437,6 @@ public:
|
||||
/// Whether to suppress printing of custom attributes that are expanded macros.
|
||||
bool SuppressExpandedMacros = true;
|
||||
|
||||
/// Suppress the @isolated(any) attribute.
|
||||
bool SuppressIsolatedAny = false;
|
||||
|
||||
/// Suppress 'isolated' and '#isolation' on isolated parameters with optional type.
|
||||
bool SuppressOptionalIsolatedParams = false;
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ BASELINE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
|
||||
BASELINE_LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
|
||||
BASELINE_LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
|
||||
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
|
||||
BASELINE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
|
||||
LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types")
|
||||
LANGUAGE_FEATURE(ObjCImplementation, 436, "@objc @implementation extensions")
|
||||
LANGUAGE_FEATURE(NonescapableTypes, 446, "Nonescapable types")
|
||||
|
||||
@@ -3234,12 +3234,6 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
|
||||
}
|
||||
}
|
||||
|
||||
static void suppressingFeatureIsolatedAny(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);
|
||||
action();
|
||||
}
|
||||
|
||||
static void
|
||||
suppressingFeatureSendingArgsAndResults(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
@@ -6544,8 +6538,7 @@ public:
|
||||
break;
|
||||
|
||||
case FunctionTypeIsolation::Kind::Erased:
|
||||
if (!Options.SuppressIsolatedAny)
|
||||
Printer << "@isolated(any) ";
|
||||
Printer << "@isolated(any) ";
|
||||
break;
|
||||
|
||||
case FunctionTypeIsolation::Kind::NonIsolatedCaller:
|
||||
|
||||
@@ -291,13 +291,6 @@ const char *IsolatedTypeAttr::getIsolationKindName(IsolationKind kind) {
|
||||
|
||||
void IsolatedTypeAttr::printImpl(ASTPrinter &printer,
|
||||
const PrintOptions &options) const {
|
||||
// Suppress the attribute if requested.
|
||||
switch (getIsolationKind()) {
|
||||
case IsolationKind::Dynamic:
|
||||
if (options.SuppressIsolatedAny) return;
|
||||
break;
|
||||
}
|
||||
|
||||
printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
|
||||
printer.printAttrName("@isolated");
|
||||
printer << "(" << getIsolationKindName() << ")";
|
||||
|
||||
@@ -361,15 +361,6 @@ UNINTERESTING_FEATURE(ClosureIsolation)
|
||||
UNINTERESTING_FEATURE(Extern)
|
||||
UNINTERESTING_FEATURE(ConsumeSelfInDeinit)
|
||||
|
||||
static bool usesFeatureIsolatedAny(Decl *decl) {
|
||||
return usesTypeMatching(decl, [](Type type) {
|
||||
if (auto fnType = type->getAs<AnyFunctionType>()) {
|
||||
return fnType->getIsolation().isErased();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
static bool usesFeatureAddressableParameters(Decl *d) {
|
||||
if (d->getAttrs().hasAttribute<AddressableSelfAttr>()) {
|
||||
return true;
|
||||
|
||||
@@ -3,21 +3,13 @@
|
||||
// RUN: %target-swift-frontend -swift-version 5 -enable-library-evolution -module-name isolated_any -emit-module -o %t/isolated_any.swiftmodule -emit-module-interface-path - %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -swift-version 5 -enable-library-evolution -module-name isolated_any -emit-module -o %t/isolated_any.swiftmodule -emit-module-interface-path - %s | %FileCheck %s
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $IsolatedAny
|
||||
// CHECK-NEXT: {{^}}public func test1(fn: @isolated(any) @Sendable () -> ())
|
||||
// CHECK-NEXT: #endif
|
||||
// CHECK: {{^}}public func test1(fn: @isolated(any) @Sendable () -> ())
|
||||
public func test1(fn: @isolated(any) @Sendable () -> ()) {}
|
||||
|
||||
// CHECK-NEXT: #if compiler(>=5.3) && $IsolatedAny
|
||||
// CHECK-NEXT: {{^}}public func test2(fn: @isolated(any) @Sendable () -> ())
|
||||
// CHECK-NEXT: #endif
|
||||
@_allowFeatureSuppression(XXX)
|
||||
public func test2(fn: @isolated(any) @Sendable () -> ()) {}
|
||||
|
||||
// CHECK-NEXT: #if compiler(>=5.3) && $IsolatedAny
|
||||
// CHECK-NEXT: {{^}}public func test3(fn: @isolated(any) @Sendable () -> ())
|
||||
// CHECK-NEXT: #else
|
||||
// CHECK-NEXT: {{^}}public func test3(fn: @Sendable () -> ())
|
||||
// CHECK-NEXT: #endif
|
||||
@_allowFeatureSuppression(IsolatedAny)
|
||||
public func test3(fn: @isolated(any) @Sendable () -> ()) {}
|
||||
Reference in New Issue
Block a user