diff --git a/include/swift/AST/DeclAttr.def b/include/swift/AST/DeclAttr.def index dee3e38927b58..65fec91ff2c69 100644 --- a/include/swift/AST/DeclAttr.def +++ b/include/swift/AST/DeclAttr.def @@ -545,6 +545,7 @@ DECL_ATTR_FEATURE_REQUIREMENT(ABI, ABIAttribute) DECL_ATTR(execution, Execution, OnFunc | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove, 166) +DECL_ATTR_FEATURE_REQUIREMENT(Execution, ExecutionAttribute) LAST_DECL_ATTR(Execution) diff --git a/include/swift/AST/PrintOptions.h b/include/swift/AST/PrintOptions.h index fbebf6be1952b..392aefeeea347 100644 --- a/include/swift/AST/PrintOptions.h +++ b/include/swift/AST/PrintOptions.h @@ -397,6 +397,9 @@ struct PrintOptions { /// Suppress modify/read accessors. bool SuppressCoroutineAccessors = false; + /// Suppress the @execution attribute + bool SuppressExecutionAttribute = false; + /// List of attribute kinds that should not be printed. std::vector ExcludeAttrList = { DeclAttrKind::Transparent, DeclAttrKind::Effects, diff --git a/include/swift/Basic/Features.def b/include/swift/Basic/Features.def index fe0484e628a2c..f46cce4d1fa3b 100644 --- a/include/swift/Basic/Features.def +++ b/include/swift/Basic/Features.def @@ -436,9 +436,13 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AddressableTypes, true) /// Allow the @abi attribute. SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ABIAttribute, true) +/// Allow the @execution attribute. This is also connected to +/// AsyncCallerExecution feature. +SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExecutionAttribute, false) + /// Functions with nonisolated isolation inherit their isolation from the /// calling context. -EXPERIMENTAL_FEATURE(NonIsolatedAsyncInheritsIsolationFromContext, false) +EXPERIMENTAL_FEATURE(AsyncCallerExecution, false) /// Allow custom availability domains to be defined and referenced. SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CustomAvailability, true) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 4561059cee434..8199a648638b3 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -3251,6 +3251,14 @@ suppressingFeatureCustomAvailability(PrintOptions &options, action(); } +static void +suppressingFeatureExecutionAttribute(PrintOptions &options, + llvm::function_ref action) { + llvm::SaveAndRestore scope1(options.SuppressExecutionAttribute, true); + ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::Execution); + action(); +} + /// Suppress the printing of a particular feature. static void suppressingFeature(PrintOptions &options, Feature feature, llvm::function_ref action) { @@ -6423,7 +6431,8 @@ class TypePrinter : public TypeVisitor { break; case FunctionTypeIsolation::Kind::NonIsolatedCaller: - Printer << "@execution(caller) "; + if (!Options.SuppressExecutionAttribute) + Printer << "@execution(caller) "; break; } diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp index 95474f9896976..1b11ad6f354d1 100644 --- a/lib/AST/Attr.cpp +++ b/lib/AST/Attr.cpp @@ -305,6 +305,9 @@ void IsolatedTypeAttr::printImpl(ASTPrinter &printer, void ExecutionTypeAttr::printImpl(ASTPrinter &printer, const PrintOptions &options) const { + if (options.SuppressExecutionAttribute) + return; + printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute); printer.printAttrName("@execution"); printer << "("; diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index 54a090bcb5916..32a27ffc20851 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -121,7 +121,7 @@ UNINTERESTING_FEATURE(Volatile) UNINTERESTING_FEATURE(SuppressedAssociatedTypes) UNINTERESTING_FEATURE(StructLetDestructuring) UNINTERESTING_FEATURE(MacrosOnImports) -UNINTERESTING_FEATURE(NonIsolatedAsyncInheritsIsolationFromContext) +UNINTERESTING_FEATURE(AsyncCallerExecution) static bool usesFeatureNonescapableTypes(Decl *decl) { auto containsNonEscapable = @@ -416,6 +416,45 @@ static bool usesFeatureBuiltinEmplaceTypedThrows(Decl *decl) { return false; } +static bool usesFeatureExecutionAttribute(Decl *decl) { + if (decl->getAttrs().hasAttribute()) + return true; + + auto VD = dyn_cast(decl); + if (!VD) + return false; + + auto hasExecutionAttr = [](TypeRepr *R) { + if (!R) + return false; + + return R->findIf([](TypeRepr *repr) { + if (auto *AT = dyn_cast(repr)) { + return llvm::any_of(AT->getAttrs(), [](TypeOrCustomAttr attr) { + if (auto *TA = attr.dyn_cast()) { + return isa(TA); + } + return false; + }); + } + return false; + }); + }; + + // Check if any parameters that have `@execution` attribute. + if (auto *PL = getParameterList(VD)) { + for (auto *P : *PL) { + if (hasExecutionAttr(P->getTypeRepr())) + return true; + } + } + + if (hasExecutionAttr(VD->getResultTypeRepr())) + return true; + + return false; +} + // ---------------------------------------------------------------------------- // MARK: - FeatureSet // ---------------------------------------------------------------------------- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 1bac7d5b8ed16..f1c61b8f74dfc 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4725,6 +4725,12 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result, } case TypeAttrKind::Execution: { + if (!Context.LangOpts.hasFeature(Feature::ExecutionAttribute)) { + diagnose(Tok, diag::requires_experimental_feature, "@execution", false, + getFeatureName(Feature::ExecutionAttribute)); + return makeParserError(); + } + SourceLoc lpLoc = Tok.getLoc(), behaviorLoc, rpLoc; if (!consumeIfNotAtStartOfLine(tok::l_paren)) { if (!justChecking) { diff --git a/lib/SIL/IR/SILFunctionType.cpp b/lib/SIL/IR/SILFunctionType.cpp index 6756ac449cb40..582c21903cfa2 100644 --- a/lib/SIL/IR/SILFunctionType.cpp +++ b/lib/SIL/IR/SILFunctionType.cpp @@ -1658,8 +1658,7 @@ class DestructureInputs { } // If we are an async function that is unspecified or nonisolated, insert an - // isolated parameter if NonIsolatedAsyncInheritsIsolationFromContext is - // enabled. + // isolated parameter if AsyncCallerExecution is enabled. if (IsolationInfo && IsolationInfo->getKind() == ActorIsolation::CallerIsolationInheriting && extInfoBuilder.isAsync()) { diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 09c7541cfbc54..d51792ca29fe0 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -4759,9 +4759,8 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true, // NOTE: This needs to occur before we handle an explicit nonisolated attr, // since if @execution and nonisolated are used together, we want to ensure // that @execution takes priority. This ensures that if we import code from a - // module that was compiled with a different value for - // NonIsolatedAsyncInheritsIsolationFromContext, we get the semantics of the - // source module. + // module that was compiled with a different value for AsyncCallerExecution, + // we get the semantics of the source module. if (concurrentExecutionAttr) { switch (concurrentExecutionAttr->getBehavior()) { case ExecutionKind::Concurrent: @@ -4777,7 +4776,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true, // If the nonisolated async inherits isolation from context is set, return // caller isolation inheriting. if (decl->getASTContext().LangOpts.hasFeature( - Feature::NonIsolatedAsyncInheritsIsolationFromContext)) { + Feature::AsyncCallerExecution)) { if (auto *func = dyn_cast(decl); func && func->hasAsync() && func->getModuleContext() == decl->getASTContext().MainModule) { @@ -5612,8 +5611,7 @@ computeDefaultInferredActorIsolation(ValueDecl *value) { } // If we have an async function... by default we inherit isolation. - if (ctx.LangOpts.hasFeature( - Feature::NonIsolatedAsyncInheritsIsolationFromContext)) { + if (ctx.LangOpts.hasFeature(Feature::AsyncCallerExecution)) { if (auto *func = dyn_cast(value); func && func->hasAsync() && func->getModuleContext() == ctx.MainModule) { @@ -5702,8 +5700,8 @@ InferredActorIsolation ActorIsolationRequest::evaluate( // did not have an ExecutionKind::Caller attached to it. // // DISCUSSION: This occurs when we have a value decl that is explicitly marked - // as nonisolated but since NonIsolatedAsyncInheritsIsolationFromContext is - // enabled, we return CallerIsolationInheriting. + // as nonisolated but since AsyncCallerExecution is enabled, we return + // CallerIsolationInheriting. if (isolationFromAttr && isolationFromAttr->getKind() == ActorIsolation::CallerIsolationInheriting && !value->getAttrs().hasAttribute()) { @@ -6001,7 +5999,7 @@ InferredActorIsolation ActorIsolationRequest::evaluate( if (auto *func = dyn_cast(value); ctx.LangOpts.hasFeature( - Feature::NonIsolatedAsyncInheritsIsolationFromContext) && + Feature::AsyncCallerExecution) && func && func->hasAsync() && func->getModuleContext() == ctx.MainModule && isolation.isNonisolated()) { diff --git a/test/ASTGen/attrs.swift b/test/ASTGen/attrs.swift index 8e59be802df73..dc9ab30ca517b 100644 --- a/test/ASTGen/attrs.swift +++ b/test/ASTGen/attrs.swift @@ -2,9 +2,9 @@ // RUN: %target-swift-frontend-dump-parse \ // RUN: -enable-experimental-feature ABIAttribute \ +// RUN: -enable-experimental-feature ExecutionAttribute \ // RUN: -enable-experimental-feature Extern \ // RUN: -enable-experimental-feature LifetimeDependence \ -// RUN: -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext \ // RUN: -enable-experimental-feature SymbolLinkageMarkers \ // RUN: -enable-experimental-move-only \ // RUN: -enable-experimental-feature ParserASTGen \ @@ -12,9 +12,9 @@ // RUN: %target-swift-frontend-dump-parse \ // RUN: -enable-experimental-feature ABIAttribute \ +// RUN: -enable-experimental-feature ExecutionAttribute \ // RUN: -enable-experimental-feature Extern \ // RUN: -enable-experimental-feature LifetimeDependence \ -// RUN: -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext \ // RUN: -enable-experimental-feature SymbolLinkageMarkers \ // RUN: -enable-experimental-move-only \ // RUN: | %sanitize-address > %t/cpp-parser.ast @@ -25,9 +25,9 @@ // RUN: -module-abi-name ASTGen \ // RUN: -enable-experimental-feature ParserASTGen \ // RUN: -enable-experimental-feature ABIAttribute \ +// RUN: -enable-experimental-feature ExecutionAttribute \ // RUN: -enable-experimental-feature Extern \ // RUN: -enable-experimental-feature LifetimeDependence \ -// RUN: -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext \ // RUN: -enable-experimental-feature SymbolLinkageMarkers \ // RUN: -enable-experimental-move-only @@ -35,9 +35,9 @@ // REQUIRES: swift_swift_parser // REQUIRES: swift_feature_ParserASTGen // REQUIRES: swift_feature_ABIAttribute +// REQUIRES: swift_feature_ExecutionAttribute // REQUIRES: swift_feature_Extern // REQUIRES: swift_feature_LifetimeDependence -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext // REQUIRES: swift_feature_SymbolLinkageMarkers // rdar://116686158 diff --git a/test/Concurrency/Runtime/nonisolated_inherits_isolation.swift b/test/Concurrency/Runtime/nonisolated_inherits_isolation.swift index 5bb0e37e021f1..e82c09d1cf49d 100644 --- a/test/Concurrency/Runtime/nonisolated_inherits_isolation.swift +++ b/test/Concurrency/Runtime/nonisolated_inherits_isolation.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift( -swift-version 6 -g %import-libdispatch -import-objc-header %S/Inputs/RunOnMainActor.h -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext ) +// RUN: %target-run-simple-swift( -swift-version 6 -g %import-libdispatch -import-objc-header %S/Inputs/RunOnMainActor.h -enable-experimental-feature ExecutionAttribute -enable-experimental-feature AsyncCallerExecution ) // REQUIRES: executable_test // REQUIRES: concurrency @@ -6,7 +6,8 @@ // REQUIRES: libdispatch // REQUIRES: asserts -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_ExecutionAttribute +// REQUIRES: swift_feature_AsyncCallerExecution // UNSUPPORTED: freestanding diff --git a/test/Concurrency/attr_execution.swift b/test/Concurrency/attr_execution.swift index dc6e198b66f61..704437d8c3220 100644 --- a/test/Concurrency/attr_execution.swift +++ b/test/Concurrency/attr_execution.swift @@ -1,7 +1,8 @@ -// RUN: %target-swift-emit-silgen -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext %s | %FileCheck %s +// RUN: %target-swift-emit-silgen -enable-experimental-feature ExecutionAttribute -enable-experimental-feature AsyncCallerExecution %s | %FileCheck %s // REQUIRES: asserts -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_ExecutionAttribute +// REQUIRES: swift_feature_AsyncCallerExecution // CHECK-LABEL: // concurrentTest() diff --git a/test/Concurrency/attr_execution_conversions.swift b/test/Concurrency/attr_execution_conversions.swift index 91c1beca31f43..e44edabb2e542 100644 --- a/test/Concurrency/attr_execution_conversions.swift +++ b/test/Concurrency/attr_execution_conversions.swift @@ -1,6 +1,8 @@ -// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple +// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple -enable-experimental-feature ExecutionAttribute +// REQUIRES: asserts // REQUIRES: concurrency +// REQUIRES: swift_feature_ExecutionAttribute @execution(concurrent) func concurrentTest() async { diff --git a/test/Concurrency/nonisolated_inherits_isolation.swift b/test/Concurrency/nonisolated_inherits_isolation.swift index 7232659319675..6916275e99713 100644 --- a/test/Concurrency/nonisolated_inherits_isolation.swift +++ b/test/Concurrency/nonisolated_inherits_isolation.swift @@ -1,12 +1,11 @@ // RUN: %target-swift-frontend %s -swift-version 6 -verify -verify-additional-prefix disabled- -c -// RUN: %target-swift-frontend %s -swift-version 6 -verify -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext -verify-additional-prefix enable- -c -verify-additional-prefix enabled- +// RUN: %target-swift-frontend %s -swift-version 6 -verify -enable-experimental-feature AsyncCallerExecution -verify-additional-prefix enable- -c -verify-additional-prefix enabled- // REQUIRES: asserts // REQUIRES: concurrency -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_AsyncCallerExecution -// This test checks and validates that when -// NonIsolatedAsyncInheritsIsolationFromContext is enabled, we emit the +// This test checks and validates that when AsyncCallerExecution is enabled, we emit the // appropriate diagnostics. It also runs with the mode off so we can validate // and compare locally against the normal errors. diff --git a/test/Concurrency/nonisolated_inherits_isolation_sema.swift b/test/Concurrency/nonisolated_inherits_isolation_sema.swift index 6a5939f071765..24dbfceea8d56 100644 --- a/test/Concurrency/nonisolated_inherits_isolation_sema.swift +++ b/test/Concurrency/nonisolated_inherits_isolation_sema.swift @@ -1,8 +1,8 @@ -// RUN: %target-typecheck-verify-swift -swift-version 6 -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext -parse-as-library +// RUN: %target-typecheck-verify-swift -swift-version 6 -enable-experimental-feature AsyncCallerExecution -parse-as-library // REQUIRES: asserts // REQUIRES: concurrency -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_AsyncCallerExecution class NonSendable {} // expected-note {{}} diff --git a/test/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index f65383713b2db..6cf7505401f2c 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -251,7 +251,6 @@ struct _S { // ON_METHOD-DAG: Keyword/None: preconcurrency[#Func Attribute#]; name=preconcurrency // ON_METHOD-DAG: Keyword/None: backDeployed[#Func Attribute#]; name=backDeployed // ON_METHOD-DAG: Keyword/None: lifetime[#Func Attribute#]; name=lifetime -// ON_METHOD-DAG: Keyword/None: execution[#Func Attribute#]; name=execution // ON_METHOD-NOT: Keyword // ON_METHOD-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct // ON_METHOD-DAG: Decl[Struct]/CurrModule: MyPropertyWrapper[#Property Wrapper#]; name=MyPropertyWrapper @@ -326,7 +325,6 @@ struct _S { // ON_MEMBER_LAST-DAG: Keyword/None: freestanding[#Declaration Attribute#]; name=freestanding // ON_MEMBER_LAST-DAG: Keyword/None: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions // ON_MEMBER_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime -// ON_MEMBER_LAST-DAG: Keyword/None: execution[#Declaration Attribute#]; name=execution // ON_MEMBER_LAST-NOT: Keyword // ON_MEMBER_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct // ON_MEMBER_LAST-DAG: Decl[Struct]/CurrModule/TypeRelation[Convertible]: MyPropertyWrapper[#Property Wrapper#]; name=MyPropertyWrapper @@ -399,7 +397,6 @@ func dummy2() {} // KEYWORD_LAST-DAG: Keyword/None: attached[#Declaration Attribute#]; name=attached // KEYWORD_LAST-DAG: Keyword/None: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions // KEYWORD_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime -// KEYWORD_LAST-DAG: Keyword/None: execution[#Declaration Attribute#]; name=execution // KEYWORD_LAST-NOT: Keyword // KEYWORD_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct // KEYWORD_LAST-DAG: Decl[Struct]/CurrModule/TypeRelation[Convertible]: MyGenericPropertyWrapper[#Property Wrapper#]; name=MyGenericPropertyWrapper diff --git a/test/IDE/complete_decl_attribute_feature_requirement.swift b/test/IDE/complete_decl_attribute_feature_requirement.swift index be7512593a37c..47977bc0e531f 100644 --- a/test/IDE/complete_decl_attribute_feature_requirement.swift +++ b/test/IDE/complete_decl_attribute_feature_requirement.swift @@ -7,7 +7,8 @@ // RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED // RUN: %batch-code-completion -filecheck-additional-suffix _ENABLED \ -// RUN: -enable-experimental-feature ABIAttribute +// RUN: -enable-experimental-feature ABIAttribute \ +// RUN: -enable-experimental-feature ExecutionAttribute // NOTE: Please do not include the ", N items" after "Begin completions". The // item count creates needless merge conflicts given that an "End completions" @@ -17,14 +18,18 @@ // KEYWORD2: Begin completions // KEYWORD2_ENABLED-DAG: Keyword/None: abi[#Func Attribute#]; name=abi +// KEYWORD2_ENABLED-DAG: Keyword/None: execution[#Func Attribute#]; name=execution // KEYWORD2_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD2_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD2: End completions @#^KEYWORD3^# class C {} // KEYWORD3: Begin completions // KEYWORD3_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD3_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD3_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD3_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD3: End completions @#^KEYWORD3_2?check=KEYWORD3^#IB class C2 {} @@ -33,46 +38,60 @@ @#^KEYWORD4^# enum E {} // KEYWORD4: Begin completions // KEYWORD4_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD4_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD4_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD4_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD4: End completions @#^KEYWORD5^# struct S{} // KEYWORD5: Begin completions // KEYWORD5_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD5_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD5_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD5_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // KEYWORD5: End completions @#^ON_GLOBALVAR^# var globalVar // ON_GLOBALVAR: Begin completions // ON_GLOBALVAR_ENABLED-DAG: Keyword/None: abi[#Var Attribute#]; name=abi +// ON_GLOBALVAR_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_GLOBALVAR_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_GLOBALVAR_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_GLOBALVAR: End completions struct _S { @#^ON_INIT^# init() // ON_INIT: Begin completions // ON_INIT_ENABLED-DAG: Keyword/None: abi[#Constructor Attribute#]; name=abi +// ON_INIT_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_INIT_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_INIT_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_INIT: End completions @#^ON_PROPERTY^# var foo // ON_PROPERTY: Begin completions // ON_PROPERTY_ENABLED-DAG: Keyword/None: abi[#Var Attribute#]; name=abi +// ON_PROPERTY_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_PROPERTY_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_PROPERTY_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_PROPERTY: End completions @#^ON_METHOD^# private func foo() // ON_METHOD: Begin completions // ON_METHOD_ENABLED-DAG: Keyword/None: abi[#Func Attribute#]; name=abi +// ON_METHOD_ENABLED-DAG: Keyword/None: execution[#Func Attribute#]; name=execution // ON_METHOD_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_METHOD_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_METHOD: End completions func bar(@#^ON_PARAM_1?check=ON_PARAM^#) // ON_PARAM: Begin completions // ON_PARAM_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_PARAM_ENABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_PARAM_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_PARAM_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_PARAM: End completions func bar( @@ -95,7 +114,9 @@ struct _S { @#^ON_MEMBER_LAST^# // ON_MEMBER_LAST: Begin completions // ON_MEMBER_LAST_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi +// ON_MEMBER_LAST_ENABLED-DAG: Keyword/None: execution[#Declaration Attribute#]; name=execution // ON_MEMBER_LAST_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// ON_MEMBER_LAST_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // ON_MEMBER_LAST: End completions } @@ -107,7 +128,9 @@ func takeClosure(_: () -> Void) { // IN_CLOSURE: Begin completions // FIXME: Not valid in this position (but CompletionLookup can't tell that) // IN_CLOSURE_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi +// IN_CLOSURE_ENABLED-DAG: Keyword/None: execution[#Declaration Attribute#]; name=execution // IN_CLOSURE_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// IN_CLOSURE_DISABLED-NOT: Keyword/None: execution[#{{.*}} Attribute#]; name=execution // IN_CLOSURE: End completions @#^KEYWORD_INDEPENDENT_1?check=KEYWORD_LAST^# @@ -123,5 +146,7 @@ func dummy2() {} // KEYWORD_LAST: Begin completions // KEYWORD_LAST_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi +// KEYWORD_LAST_ENABLED-DAG: Keyword/None: execution[#Declaration Attribute#]; name=execution // KEYWORD_LAST_DISABLED-NOT: Keyword/None: abi[#Declaration Attribute#]; name=abi +// KEYWORD_LAST_DISABLED-NOT: Keyword/None: execution[#Declaration Attribute#]; name=execution // KEYWORD_LAST: End completions diff --git a/test/ModuleInterface/attrs.swift b/test/ModuleInterface/attrs.swift index 32be2a3c58120..cbda5e5ca8e01 100644 --- a/test/ModuleInterface/attrs.swift +++ b/test/ModuleInterface/attrs.swift @@ -1,13 +1,13 @@ // RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name attrs \ // RUN: -enable-experimental-feature ABIAttribute \ -// RUN: -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext +// RUN: -enable-experimental-feature ExecutionAttribute // RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name attrs // RUN: %FileCheck %s --input-file %t.swiftinterface // REQUIRES: swift_feature_ABIAttribute -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_ExecutionAttribute // CHECK: @_transparent public func glass() -> Swift.Int { return 0 }{{$}} @_transparent public func glass() -> Int { return 0 } diff --git a/test/ModuleInterface/execution_attr.swift b/test/ModuleInterface/execution_attr.swift new file mode 100644 index 0000000000000..e5f26cd8f0cdd --- /dev/null +++ b/test/ModuleInterface/execution_attr.swift @@ -0,0 +1,25 @@ +// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name execution_attr -enable-experimental-feature ExecutionAttribute +// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name execution_attr + +// RUN: %FileCheck %s --input-file %t.swiftinterface + +// REQUIRES: swift_feature_ExecutionAttribute + +public struct Test { + // CHECK: #if compiler(>=5.3) && $ExecutionAttribute + // CHECK-NEXT: @execution(concurrent) public func test() async + // CHECK-NEXT: #else + // CHECK-NEXT: public func test() async + // CHECK-NEXT: #endif + @execution(concurrent) + public func test() async { + } + + // CHECK: #if compiler(>=5.3) && $ExecutionAttribute + // CHECK-NEXT: public func other(_: @execution(caller) () async -> Swift.Void) + // CHECK-NEXT: #else + // CHECK-NEXT: public func other(_: () async -> Swift.Void) + // CHECK-NEXT: #endif + public func other(_: @execution(caller) () async -> Void) {} +} + diff --git a/test/Parse/execution.swift b/test/Parse/execution.swift index 124c6967fab58..08ac14a050d2b 100644 --- a/test/Parse/execution.swift +++ b/test/Parse/execution.swift @@ -1,4 +1,8 @@ -// RUN: %target-typecheck-verify-swift -disable-availability-checking +// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-feature ExecutionAttribute + +// REQUIRES: asserts +// REQUIRES: concurrency +// REQUIRES: swift_feature_ExecutionAttribute typealias F = @execution(concurrent) () async -> Void diff --git a/test/SILGen/execution_attr.swift b/test/SILGen/execution_attr.swift index e6e070e51d5dc..c6449cdf78919 100644 --- a/test/SILGen/execution_attr.swift +++ b/test/SILGen/execution_attr.swift @@ -1,9 +1,10 @@ -// RUN: %target-swift-emit-silgen %s | %FileCheck %s -// RUN: %target-swift-emit-silgen %s -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext | %FileCheck %s +// RUN: %target-swift-emit-silgen %s -enable-experimental-feature ExecutionAttribute | %FileCheck %s +// RUN: %target-swift-emit-silgen %s -enable-experimental-feature ExecutionAttribute -enable-experimental-feature AsyncCallerExecution | %FileCheck %s // REQUIRES: concurrency // REQUIRES: asserts -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_ExecutionAttribute +// REQUIRES: swift_feature_AsyncCallerExecution // Validate that both with and without the experimental flag we properly codegen // execution(caller) and execution(concurrent). diff --git a/test/SILGen/nonisolated_inherits_isolation.swift b/test/SILGen/nonisolated_inherits_isolation.swift index 5bbbe38a146ad..f0fefae4da1a6 100644 --- a/test/SILGen/nonisolated_inherits_isolation.swift +++ b/test/SILGen/nonisolated_inherits_isolation.swift @@ -1,8 +1,8 @@ -// RUN: %target-swift-emit-silgen -swift-version 6 -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext %s | %FileCheck %s +// RUN: %target-swift-emit-silgen -swift-version 6 -enable-experimental-feature AsyncCallerExecution %s | %FileCheck %s // REQUIRES: concurrency // REQUIRES: asserts -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_AsyncCallerExecution //===----------------------------------------------------------------------===// // MARK: Declarations diff --git a/test/Serialization/caller_isolation_inherit.swift b/test/Serialization/caller_isolation_inherit.swift index cfa1d41f0df66..d58f749dd0b62 100644 --- a/test/Serialization/caller_isolation_inherit.swift +++ b/test/Serialization/caller_isolation_inherit.swift @@ -1,13 +1,14 @@ // RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext -emit-module-path %t/WithFeature.swiftmodule -module-name WithFeature %S/Inputs/caller_inheriting_isolation.swift -swift-version 6 -// RUN: %target-swift-frontend -emit-module-path %t/WithoutFeature.swiftmodule -module-name WithoutFeature %S/Inputs/caller_inheriting_isolation.swift -swift-version 6 +// RUN: %target-swift-frontend -enable-experimental-feature ExecutionAttribute -enable-experimental-feature AsyncCallerExecution -emit-module-path %t/WithFeature.swiftmodule -module-name WithFeature %S/Inputs/caller_inheriting_isolation.swift -swift-version 6 +// RUN: %target-swift-frontend -enable-experimental-feature ExecutionAttribute -emit-module-path %t/WithoutFeature.swiftmodule -module-name WithoutFeature %S/Inputs/caller_inheriting_isolation.swift -swift-version 6 // RUN: %target-swift-frontend -module-name main -I %t %s -emit-sil -o - | %FileCheck %s -// RUN: %target-swift-frontend -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext -module-name main -I %t %s -emit-sil -verify -swift-version 6 +// RUN: %target-swift-frontend -enable-experimental-feature ExecutionAttribute -enable-experimental-feature AsyncCallerExecution -module-name main -I %t %s -emit-sil -verify -swift-version 6 // REQUIRES: asserts -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_ExecutionAttribute +// REQUIRES: swift_feature_AsyncCallerExecution import WithFeature import WithoutFeature diff --git a/test/attr/attr_execution.swift b/test/attr/attr_execution.swift index 6b9596db2ece3..4f7c283d8ca8f 100644 --- a/test/attr/attr_execution.swift +++ b/test/attr/attr_execution.swift @@ -1,7 +1,7 @@ -// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext +// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple -enable-experimental-feature ExecutionAttribute // REQUIRES: concurrency -// REQUIRES: swift_feature_NonIsolatedAsyncInheritsIsolationFromContext +// REQUIRES: swift_feature_ExecutionAttribute @execution(something) func invalidAttr() async {} // expected-error {{unknown option 'something' for attribute 'execution'}}