AST: Re-baseline SendingArgsAndResults feature.

This commit is contained in:
Allan Shortlidge
2025-07-29 15:56:23 -07:00
parent a37ce9a543
commit 2b8ab7fbab
10 changed files with 25 additions and 273 deletions

View File

@@ -436,9 +436,6 @@ public:
/// Suppress 'isolated' and '#isolation' on isolated parameters with optional type.
bool SuppressOptionalIsolatedParams = false;
/// Suppress 'sending' on arguments and results.
bool SuppressSendingArgsAndResults = false;
/// Suppress printing of '~Proto' for suppressible, non-invertible protocols.
bool SuppressConformanceSuppression = false;

View File

@@ -248,7 +248,7 @@ BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics2, 427, "Noncopyable generics alias
BASELINE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
BASELINE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
BASELINE_LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
BASELINE_LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
BASELINE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types")

View File

@@ -1172,8 +1172,7 @@ public:
return true;
if (isCallerIsolatedSpecifier())
return true;
if (Context.LangOpts.hasFeature(Feature::SendingArgsAndResults) &&
Tok.isContextualKeyword("sending"))
if (Tok.isContextualKeyword("sending"))
return true;
return false;
}

View File

@@ -3220,13 +3220,6 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
}
}
static void
suppressingFeatureSendingArgsAndResults(PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> scope(options.SuppressSendingArgsAndResults, true);
action();
}
static void
suppressingFeatureLifetimes(PrintOptions &options,
llvm::function_ref<void()> action) {
@@ -3854,17 +3847,7 @@ static void printParameterFlags(ASTPrinter &printer,
}
if (flags.isSending()) {
if (!options.SuppressSendingArgsAndResults) {
printer.printKeyword("sending", options, " ");
} else if (flags.getOwnershipSpecifier() ==
ParamSpecifier::ImplicitlyCopyableConsuming) {
// Ok. We are suppressing sending. If our ownership specifier was
// originally implicitly copyable consuming our argument was being passed
// at +1. By not printing sending, we would be changing the API
// potentially to take the parameter at +0 instead of +1. To work around
// this, print out consuming so that we preserve the +1 parameter.
printer.printKeyword("__owned", options, " ");
}
printer.printKeyword("sending", options, " ");
}
if (flags.isIsolated()) {
@@ -4327,14 +4310,12 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
Printer.printDeclResultTypePre(decl, ResultTyLoc);
Printer.callPrintStructurePre(PrintStructureKind::FunctionReturnType);
if (!Options.SuppressSendingArgsAndResults) {
if (decl->hasSendingResult()) {
if (decl->hasSendingResult()) {
Printer << "sending ";
} else if (auto *ft = llvm::dyn_cast_if_present<AnyFunctionType>(
decl->getInterfaceType())) {
if (ft->hasExtInfo() && ft->hasSendingResult()) {
Printer << "sending ";
} else if (auto *ft = llvm::dyn_cast_if_present<AnyFunctionType>(
decl->getInterfaceType())) {
if (ft->hasExtInfo() && ft->hasSendingResult()) {
Printer << "sending ";
}
}
}
@@ -4507,12 +4488,10 @@ void PrintAST::visitSubscriptDecl(SubscriptDecl *decl) {
Printer.printDeclResultTypePre(decl, elementTy);
Printer.callPrintStructurePre(PrintStructureKind::FunctionReturnType);
if (!Options.SuppressSendingArgsAndResults) {
if (decl->getElementTypeRepr()) {
if (isa<SendingTypeRepr>(decl->getResultTypeRepr()))
Printer << "sending ";
}
}
PrintWithOpaqueResultTypeKeywordRAII x(Options);
auto nrOptions = getNonRecursiveOptions(decl);
@@ -6798,8 +6777,7 @@ public:
Printer << " -> ";
if (!Options.SuppressSendingArgsAndResults && T->hasExtInfo() &&
T->hasSendingResult()) {
if (T->hasExtInfo() && T->hasSendingResult()) {
Printer.printKeyword("sending ", Options);
}

View File

@@ -140,56 +140,7 @@ UNINTERESTING_FEATURE(StaticExclusiveOnly)
UNINTERESTING_FEATURE(ExtractConstantsFromMembers)
UNINTERESTING_FEATURE(GroupActorErrors)
UNINTERESTING_FEATURE(SameElementRequirements)
static bool usesFeatureSendingArgsAndResults(Decl *decl) {
auto isFunctionTypeWithSending = [](Type type) {
auto fnType = type->getAs<AnyFunctionType>();
if (!fnType)
return false;
if (fnType->hasExtInfo() && fnType->hasSendingResult())
return true;
return llvm::any_of(fnType->getParams(),
[](AnyFunctionType::Param param) {
return param.getParameterFlags().isSending();
});
};
auto declUsesFunctionTypesThatUseSending = [&](Decl *decl) {
return usesTypeMatching(decl, isFunctionTypeWithSending);
};
if (auto *pd = dyn_cast<ParamDecl>(decl)) {
if (pd->isSending()) {
return true;
}
if (declUsesFunctionTypesThatUseSending(pd))
return true;
}
if (auto *fDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
// First check for param decl results.
if (llvm::any_of(fDecl->getParameters()->getArray(), [](ParamDecl *pd) {
return usesFeatureSendingArgsAndResults(pd);
}))
return true;
if (declUsesFunctionTypesThatUseSending(decl))
return true;
}
// Check if we have a pattern binding decl for a function that has sending
// parameters and results.
if (auto *pbd = dyn_cast<PatternBindingDecl>(decl)) {
for (auto index : range(pbd->getNumPatternEntries())) {
auto *pattern = pbd->getPattern(index);
if (pattern->hasType() && isFunctionTypeWithSending(pattern->getType()))
return true;
}
}
return false;
}
UNINTERESTING_FEATURE(SendingArgsAndResults)
static bool findUnderscoredLifetimeAttr(Decl *decl) {
auto hasUnderscoredLifetimeAttr = [](Decl *decl) {

View File

@@ -472,20 +472,7 @@ void FunctionTypeRepr::printImpl(ASTPrinter &Printer,
Printer << " -> ";
Printer.callPrintStructurePre(PrintStructureKind::FunctionReturnType);
// Check if we are supposed to suppress sending results. If so, look through
// the ret ty if it is a Sending TypeRepr.
//
// DISCUSSION: The reason why we do this is that Sending TypeRepr is used for
// arguments and results... and we need the arguments case when we suppress to
// print __owned. So this lets us handle both cases.
auto ActualRetTy = RetTy;
if (Opts.SuppressSendingArgsAndResults) {
if (auto *x = dyn_cast<SendingTypeRepr>(RetTy)) {
ActualRetTy = x->getBase();
}
}
printTypeRepr(ActualRetTy, Printer, Opts);
printTypeRepr(RetTy, Printer, Opts);
Printer.printStructurePost(PrintStructureKind::FunctionReturnType);
Printer.printStructurePost(PrintStructureKind::FunctionType);
}
@@ -926,13 +913,7 @@ void SpecifierTypeRepr::printImpl(ASTPrinter &Printer,
Printer.printKeyword("isolated", Opts, " ");
break;
case TypeReprKind::Sending:
// This handles the argument case. The result case is handled in
// FunctionTypeRepr.
if (!Opts.SuppressSendingArgsAndResults) {
Printer.printKeyword("sending", Opts, " ");
} else {
Printer.printKeyword("__owned", Opts, " ");
}
Printer.printKeyword("sending", Opts, " ");
break;
case TypeReprKind::CompileTimeLiteral:
Printer.printKeyword("_const", Opts, " ");

View File

@@ -1,220 +1,107 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-upcoming-feature SendingArgsAndResults -swift-version 5 -enable-library-evolution -module-name test -emit-module -o %t/test.swiftmodule -emit-module-interface-path - -target %target-swift-5.1-abi-triple -Xllvm -swift-ast-printer-number-suppression-checks %s | %FileCheck %s
// RUN: %target-swift-frontend -enable-upcoming-feature SendingArgsAndResults -swift-version 5 -enable-library-evolution -module-name test -emit-module -o %t/test.swiftmodule -emit-module-interface-path - -target %target-swift-5.1-abi-triple %s | %FileCheck %s
// REQUIRES: swift_feature_SendingArgsAndResults
// REQUIRES: asserts
public class NonSendableKlass {}
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func transferArgTest(_ x: sending test.NonSendableKlass)
// CHECK-NEXT: #else
// When we suppress, we preserve +1 by marking the parameter as __owned. Otherwise, we
// be breaking ABI.
// CHECK-NEXT: public func transferArgTest(_ x: __owned test.NonSendableKlass)
// CHECK-NEXT: #endif
// CHECK: public func transferArgTest(_ x: sending test.NonSendableKlass)
public func transferArgTest(_ x: sending NonSendableKlass) {}
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func transferResultTest() -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func transferResultTest() -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func transferResultTest() -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func transferArgAndResultTest(_ x: test.NonSendableKlass, _ y: sending test.NonSendableKlass, _ z: test.NonSendableKlass) -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func transferArgAndResultTest(_ x: test.NonSendableKlass, _ y: __owned test.NonSendableKlass, _ z: test.NonSendableKlass) -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func transferArgAndResultTest(_ x: NonSendableKlass, _ y: sending NonSendableKlass, _ z: NonSendableKlass) -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func argEmbeddedInType(_ fn: (sending test.NonSendableKlass) -> ())
// CHECK-NEXT: #else
// CHECK-NEXT: public func argEmbeddedInType(_ fn: (__owned test.NonSendableKlass) -> ())
// CHECK-NEXT: #endif
public func argEmbeddedInType(_ fn: (sending NonSendableKlass) -> ()) {}
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func resultEmbeddedInType(_ fn: () -> sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: public func resultEmbeddedInType(_ fn: () -> test.NonSendableKlass)
// CHECK-NEXT: #endif
public func resultEmbeddedInType(_ fn: () -> sending NonSendableKlass) {}
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func argAndResultEmbeddedInType(_ fn: (test.NonSendableKlass, sending test.NonSendableKlass, test.NonSendableKlass) -> sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: public func argAndResultEmbeddedInType(_ fn: (test.NonSendableKlass, __owned test.NonSendableKlass, test.NonSendableKlass) -> test.NonSendableKlass)
// CHECK-NEXT: #endif
public func argAndResultEmbeddedInType(_ fn: (NonSendableKlass, sending NonSendableKlass, NonSendableKlass) -> sending NonSendableKlass) {}
// CHECK-LABEL: public class TestInKlass
public class TestInKlass {
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testKlassArg(_ x: sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: public func testKlassArg(_ x: __owned test.NonSendableKlass)
// CHECK-NEXT: #endif
public func testKlassArg(_ x: sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testKlassResult() -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func testKlassResult() -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func testKlassResult() -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testKlassArgAndResult(_ x: test.NonSendableKlass, _ y: sending test.NonSendableKlass, z: test.NonSendableKlass) -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func testKlassArgAndResult(_ x: test.NonSendableKlass, _ y: __owned test.NonSendableKlass, z: test.NonSendableKlass) -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func testKlassArgAndResult(_ x: NonSendableKlass, _ y: sending NonSendableKlass, z: NonSendableKlass) -> sending NonSendableKlass { fatalError() }
}
// CHECK-LABEL: public struct TestInStruct
public struct TestInStruct {
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testKlassArg(_ x: sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: public func testKlassArg(_ x: __owned test.NonSendableKlass)
// CHECK-NEXT: #endif
public func testKlassArg(_ x: sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testKlassResult() -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func testKlassResult() -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func testKlassResult() -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testKlassArgAndResult(_ x: test.NonSendableKlass, _ y: sending test.NonSendableKlass, z: test.NonSendableKlass) -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func testKlassArgAndResult(_ x: test.NonSendableKlass, _ y: __owned test.NonSendableKlass, z: test.NonSendableKlass) -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func testKlassArgAndResult(_ x: NonSendableKlass, _ y: sending NonSendableKlass, z: NonSendableKlass) -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testFunctionArg(_ x: () -> sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: public func testFunctionArg(_ x: () -> test.NonSendableKlass)
// CHECK-NEXT: #endif
public func testFunctionArg(_ x: () -> sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func testFunctionResult() -> () -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func testFunctionResult() -> () -> test.NonSendableKlass
// CHECK-NEXT: #endif
public func testFunctionResult() -> (() -> sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineKlassArg(_ x: sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineKlassArg(_ x: __owned test.NonSendableKlass)
// CHECK-NEXT: #endif
@usableFromInline func testUsableFromInlineKlassArg(_ x: sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineKlassResult() -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineKlassResult() -> test.NonSendableKlass
// CHECK-NEXT: #endif
@usableFromInline
func testUsableFromInlineKlassResult() -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineKlassArgAndResult(_ x: test.NonSendableKlass, _ y: sending test.NonSendableKlass, z: test.NonSendableKlass) -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineKlassArgAndResult(_ x: test.NonSendableKlass, _ y: __owned test.NonSendableKlass, z: test.NonSendableKlass) -> test.NonSendableKlass
// CHECK-NEXT: #endif
@usableFromInline
func testUsableFromInlineKlassArgAndResult(_ x: NonSendableKlass, _ y: sending NonSendableKlass, z: NonSendableKlass) -> sending NonSendableKlass { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineFunctionArg(_ x: () -> sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineFunctionArg(_ x: () -> test.NonSendableKlass)
// CHECK-NEXT: #endif
@usableFromInline
func testUsableFromInlineFunctionArg(_ x: () -> sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineFunctionResult() -> () -> sending test.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal func testUsableFromInlineFunctionResult() -> () -> test.NonSendableKlass
// CHECK-NEXT: #endif
@usableFromInline
func testUsableFromInlineFunctionResult() -> (() -> sending NonSendableKlass) { fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public var publicVarFieldFunctionArg: (sending test.NonSendableKlass) -> ()
// CHECK-NEXT: #else
// CHECK-NEXT: public var publicVarFieldFunctionArg: (__owned test.NonSendableKlass) -> ()
// CHECK-NEXT: #endif
public var publicVarFieldFunctionArg: (sending NonSendableKlass) -> ()
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal var internalVarFieldFunctionArg: (sending test.NonSendableKlass) -> ()
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal var internalVarFieldFunctionArg: (__owned test.NonSendableKlass) -> ()
// CHECK-NEXT: #endif
@usableFromInline
var internalVarFieldFunctionArg: (sending NonSendableKlass) -> ()
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public let publicLetFieldFunctionArg: (sending test.NonSendableKlass) -> ()
// CHECK-NEXT: #else
// CHECK-NEXT: public let publicLetFieldFunctionArg: (__owned test.NonSendableKlass) -> ()
// CHECK-NEXT: #endif
public let publicLetFieldFunctionArg: (sending NonSendableKlass) -> ()
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal let internalLetFieldFunctionArg: (sending test.NonSendableKlass) -> ()
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal let internalLetFieldFunctionArg: (__owned test.NonSendableKlass) -> ()
// CHECK-NEXT: #endif
@usableFromInline
let internalLetFieldFunctionArg: (sending NonSendableKlass) -> ()
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal init(_ x: Swift.Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal init(_ x: Swift.Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass)
// CHECK-NEXT: #endif
@usableFromInline
internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending NonSendableKlass) { fatalError() }
}
// Make sure that we emit compiler(>= 5.3) when emitting the suppressing check
// to make sure we do not fail if we fail to parse sending in the if block.
// CHECK: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 24
// CHECK-NEXT: @inlinable public func withCheckedContinuation<T>(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void) async -> sending T {
// CHECK-LABEL: @inlinable public func withCheckedContinuation<T>(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void) async -> sending T {
// CHECK-NEXT: fatalError()
// CHECK-NEXT: }
// CHECK-NEXT: #else
// CHECK-NEXT: @inlinable public func withCheckedContinuation<T>(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void) async -> T {
// CHECK-NEXT: fatalError()
// CHECK-NEXT: }
// CHECK-NEXT: #endif
@inlinable public func withCheckedContinuation<T>(
isolation: isolated (any _Concurrency.Actor)? = #isolation,
function: String = #function,
@@ -223,19 +110,10 @@ public struct TestInStruct {
fatalError()
}
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 25
// CHECK-NEXT: public var publicGlobal: (sending test.NonSendableKlass) -> ()
// CHECK-NEXT: #else
// CHECK-NEXT: public var publicGlobal: (__owned test.NonSendableKlass) -> ()
// CHECK-NEXT: #endif
// CHECK-LABEL: public var publicGlobal: (sending test.NonSendableKlass) -> ()
public var publicGlobal: (sending NonSendableKlass) -> () = { x in fatalError() }
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 26
// CHECK-NEXT: @usableFromInline
// CHECK: @usableFromInline
// CHECK-NEXT: internal var usableFromInlineGlobal: (sending test.NonSendableKlass) -> ()
// CHECK-NEXT: #else
// CHECK-NEXT: @usableFromInline
// CHECK-NEXT: internal var usableFromInlineGlobal: (__owned test.NonSendableKlass) -> ()
// CHECK-NEXT: #endif
@usableFromInline
internal var usableFromInlineGlobal: (sending NonSendableKlass) -> () = { x in fatalError() }

View File

@@ -11,41 +11,17 @@
public class NonSendableKlass {}
// CHECK: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func test() -> sending MyFile.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: public func test() -> MyFile.NonSendableKlass
// CHECK-NEXT: #endif
// CHECK: public func test() -> sending MyFile.NonSendableKlass
// CHECK-REPR: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-REPR-NEXT: public func test() -> sending NonSendableKlass
// CHECK-REPR-NEXT: #else
// CHECK-REPR-NEXT: public func test() -> NonSendableKlass
// CHECK-REPR-NEXT: #endif
// CHECK-REPR: public func test() -> sending NonSendableKlass
public func test() -> sending NonSendableKlass { NonSendableKlass() }
// CHECK: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public func test2(_ x: sending MyFile.NonSendableKlass)
// CHECK-NEXT: #else
// CHECK-NEXT: public func test2(_ x: __owned MyFile.NonSendableKlass)
// CHECK-NEXT: #endif
// CHECK: public func test2(_ x: sending MyFile.NonSendableKlass)
// CHECK-REPR: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-REPR-NEXT: public func test2(_ x: sending NonSendableKlass)
// CHECK-REPR-NEXT: #else
// CHECK-REPR-NEXT: public func test2(_ x: __owned NonSendableKlass)
// CHECK-REPR-NEXT: #endif
// CHECK-REPR: public func test2(_ x: sending NonSendableKlass)
public func test2(_ x: sending NonSendableKlass) {}
// CHECK: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: @_Concurrency.MainActor public var closure: () -> sending MyFile.NonSendableKlass
// CHECK-NEXT: #else
// CHECK-NEXT: @_Concurrency.MainActor public var closure: () -> MyFile.NonSendableKlass
// CHECK-NEXT: #endif
// CHECK: @_Concurrency.MainActor public var closure: () -> sending MyFile.NonSendableKlass
// CHECK-REPR: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-REPR-NEXT: @_Concurrency.MainActor public var closure: () -> sending NonSendableKlass
// CHECK-REPR-NEXT: #else
// CHECK-REPR-NEXT: @_Concurrency.MainActor public var closure: () -> NonSendableKlass
// CHECK-REPR-NEXT: #endif
// CHECK-REPR: @_Concurrency.MainActor public var closure: () -> sending NonSendableKlass
@MainActor public var closure: () -> sending NonSendableKlass = { NonSendableKlass() }

View File

@@ -88,10 +88,6 @@ public func sendingABI() -> Any? { nil }
// CHECK: #if {{.*}} && $ABIAttributeSE0479
// CHECK: @abi(func sendingABI() -> sending Any?)
// CHECK: public func sendingABI() -> Any?
// CHECK: #elseif {{.*}} && $SendingArgsAndResults
// CHECK: @_silgen_name("$s5attrs10sendingABIypSgyF")
// CHECK: public func sendingABI() -> Any?
// CHECK: #else
// CHECK: @_silgen_name("$s5attrs10sendingABIypSgyF")
// CHECK: public func sendingABI() -> Any?
// CHECK: #endif

View File

@@ -20,11 +20,7 @@ public struct Test {
public init(@_inheritActorContext x: @Sendable () async -> Int) {}
// CHECK: #if compiler(>=5.3) && $AlwaysInheritActorContext
// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults
// CHECK-NEXT: public init(@_inheritActorContext(always) y: sending () async -> Swift.Void)
// CHECK-NEXT: #else
// CHECK-NEXT: public init(@_inheritActorContext(always) y: () async -> Swift.Void)
// CHECK-NEXT: #endif
// CHECK-NEXT: #endif
public init(@_inheritActorContext(always) y: sending () async -> Void) {}