From 521a70f4167ddcbd820aa10186b5fa0d6670ac40 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2024 16:44:51 -0700 Subject: [PATCH 1/7] [ast] Always emit compiler(>= 5.3) when emitting guards for suppressable features to guard against parser errors. The code here was assuming that if we already emitted a compiler guard for non-Suppressable features, we could avoid doing it for suppressable features. The problem with this is that compiler() does more than just check for compiler versions... it also tells the compiler that parser errors in the if block should be ignored when if evaluates to false. rdar://129045783 --- lib/AST/ASTPrinter.cpp | 9 ++++++--- .../sending_conditional_suppression.swift | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 96a87ab160763..0e2aab293a625 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -3289,10 +3289,13 @@ void swift::printWithCompatibilityFeatureChecks(ASTPrinter &printer, // features, or else just print the body. if (features.hasAnySuppressible()) { auto generator = features.generateSuppressibleFeatures(); + + // NOTE: We emit the compiler check here as well since that also implicitly + // ensures that we ignore parsing errors in the if block. It is harmless + // otherwise. printWithSuppressibleFeatureChecks(printer, options, - /*first*/ true, - /*compiler check*/ !hasRequiredFeatures, - generator, + /*first*/ true, + /*compiler check*/ true, generator, printBody); } else { printBody(); diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index 0fa0ab7549ecb..0deae0de04343 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -91,3 +91,23 @@ public struct TestInStruct { // CHECK-NEXT: #endif public func testKlassArgAndResult(_ x: NonSendableKlass, _ y: sending NonSendableKlass, z: NonSendableKlass) -> 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) && $OptionalIsolatedParameters && $ExpressionMacroDefaultArguments +// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults +// CHECK-NEXT: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) +// CHECK-NEXT: @backDeployed(before: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999) +// CHECK-NEXT: @inlinable public func withCheckedContinuation(isolation: +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) +@backDeployed(before: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999) +@inlinable public func withCheckedContinuation( + isolation: isolated (any _Concurrency.Actor)? = #isolation, + function: String = #function, + _ body: (_Concurrency.CheckedContinuation) -> Swift.Void +) async -> sending T { + return await withUnsafeContinuation { + body(CheckedContinuation(continuation: $0, function: function)) + } +} From 97710b477304396d49644afec6ef0f016cd8e63d Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2024 18:00:23 -0700 Subject: [PATCH 2/7] [sending] Add some more test coverage for public/internal methods of NominalTypes. These already worked... I am just adding the code coverage before I fix a different issue in the next commit. This will make it clearer what I am actually fixing in the next commit when one reads the tests. --- .../sending_conditional_suppression.swift | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index 0deae0de04343..33db1a826e32d 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -90,6 +90,69 @@ public struct TestInStruct { // CHECK-NEXT: public func testKlassArgAndResult(_ x: test.NonSendableKlass, _ y: 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: 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: 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() } } // Make sure that we emit compiler(>= 5.3) when emitting the suppressing check From 14c4576889b06f44aaf88e3fc7a534c7ef9c91b4 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2024 18:01:36 -0700 Subject: [PATCH 3/7] [sending] Make it so that we suppress fields of Nominal Types in API notes. rdar://129045783 --- lib/AST/FeatureSet.cpp | 21 +++++++++--- .../sending_conditional_suppression.swift | 34 +++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index 64eac20571a5f..5763fc4e27250 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -647,8 +647,7 @@ UNINTERESTING_FEATURE(GroupActorErrors) UNINTERESTING_FEATURE(TransferringArgsAndResults) static bool usesFeatureSendingArgsAndResults(Decl *decl) { - auto functionTypeUsesSending = [](Decl *decl) { - return usesTypeMatching(decl, [](Type type) { + auto isFunctionTypeWithSending = [](Type type) { auto fnType = type->getAs(); if (!fnType) return false; @@ -660,7 +659,9 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) { [](AnyFunctionType::Param param) { return param.getParameterFlags().isSending(); }); - }); + }; + auto declUsesFunctionTypesThatUseSending = [&](Decl *decl) { + return usesTypeMatching(decl, isFunctionTypeWithSending); }; if (auto *pd = dyn_cast(decl)) { @@ -668,7 +669,7 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) { return true; } - if (functionTypeUsesSending(pd)) + if (declUsesFunctionTypesThatUseSending(pd)) return true; } @@ -678,10 +679,20 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) { return usesFeatureSendingArgsAndResults(pd); })) return true; - if (functionTypeUsesSending(decl)) + 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(decl)) { + for (auto index : range(pbd->getNumPatternEntries())) { + auto *pattern = pbd->getPattern(index); + if (pattern->hasType() && isFunctionTypeWithSending(pattern->getType())) + return true; + } + } + return false; } diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index 33db1a826e32d..3b4790d6b7afb 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -153,6 +153,40 @@ public struct TestInStruct { // 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: (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: (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: (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: (test.NonSendableKlass) -> () + // CHECK-NEXT: #endif + @usableFromInline + let internalLetFieldFunctionArg: (sending NonSendableKlass) -> () } // Make sure that we emit compiler(>= 5.3) when emitting the suppressing check From 11f86a548852acc694c21afe56e040dd13092325 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2024 19:11:46 -0700 Subject: [PATCH 4/7] [sending] Teach sending how to suppress sending from functions passed to inits. rdar://129045783 --- lib/AST/FeatureSet.cpp | 2 +- .../sending_conditional_suppression.swift | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index 5763fc4e27250..6cbb9e653b80a 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -673,7 +673,7 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) { return true; } - if (auto *fDecl = dyn_cast(decl)) { + if (auto *fDecl = dyn_cast(decl)) { // First check for param decl results. if (llvm::any_of(fDecl->getParameters()->getArray(), [](ParamDecl *pd) { return usesFeatureSendingArgsAndResults(pd); diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index 3b4790d6b7afb..1d4f2768b80f4 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -95,14 +95,14 @@ public struct TestInStruct { // CHECK-NEXT: public func testFunctionArg(_ x: () -> sending test.NonSendableKlass) // CHECK-NEXT: #else // CHECK-NEXT: public func testFunctionArg(_ x: () -> test.NonSendableKlass) - // CHECK-NEXT: #endif + // 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 + // CHECK-NEXT: #endif public func testFunctionResult() -> (() -> sending NonSendableKlass) { fatalError() } // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults @@ -187,6 +187,16 @@ public struct TestInStruct { // CHECK-NEXT: #endif @usableFromInline let internalLetFieldFunctionArg: (sending NonSendableKlass) -> () + + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults + // CHECK-NEXT: @usableFromInline + // CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass) { fatalError() } + // CHECK-NEXT: #else + // CHECK-NEXT: @usableFromInline + // CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass) { fatalError() } + // 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 From f7bbbbeea2c990df2407969887c08a7610289386 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2024 19:45:22 -0700 Subject: [PATCH 5/7] [ast] Add an asserts only option that causes the AST printer to print out an increasing ID for all suppressed statements. I am using this to better test out suppression statements. I am finding that FileCheck runs into issues with some of the '#if' lines I am trying to match. I am able to use this option with my asserts only test to uniquely identify a '#if ...' statement and thus have the pattern matching work. I needed this to get the test in the next commit to pass testing. --- lib/AST/ASTPrinter.cpp | 19 +++++++++++++++++++ .../sending_conditional_suppression.swift | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 0e2aab293a625..de6f7c758dda7 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -62,6 +62,7 @@ #include "clang/Lex/MacroInfo.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/SaveAndRestore.h" @@ -71,6 +72,15 @@ using namespace swift; +#ifndef NDEBUG +static llvm::cl::opt NumberSuppressionChecks( + "swift-ast-printer-number-suppression-checks", + llvm::cl::desc("Used to number suppression checks in swift interface files " + "to make it easier to FileCheck them. Only available with " + "asserts enabled and intended for compiler tests."), + llvm::cl::init(false), llvm::cl::Hidden); +#endif + // Defined here to avoid repeatedly paying the price of template instantiation. const std::function PrintOptions::defaultPrintExtensionContentAsMembers @@ -3199,6 +3209,15 @@ static void printCompatibilityCheckIf(ASTPrinter &printer, bool isElseIf, } printer << "$" << getFeatureName(feature); } + +#ifndef NDEBUG + if (NumberSuppressionChecks) { + static unsigned totalSuppressionChecks = 0; + printer << " // Suppression Count: " << totalSuppressionChecks; + ++totalSuppressionChecks; + } +#endif + printer.printNewline(); } diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index 1d4f2768b80f4..bc6a7beee4421 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -1,6 +1,8 @@ // 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 - %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 - -disable-availability-checking -swift-ast-printer-number-suppression-checks %s | %FileCheck %s + +// REQUIRES: asserts public class NonSendableKlass {} From bfb5096e81b92446b26d3491f7c256c3bd00dda7 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 30 May 2024 19:27:22 -0700 Subject: [PATCH 6/7] [sending] Add some code coverage for globals. --- .../sending_conditional_suppression.swift | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index bc6a7beee4421..7a72efda208fd 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -192,10 +192,10 @@ public struct TestInStruct { // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // CHECK-NEXT: @usableFromInline - // CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass) { fatalError() } + // 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: Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass) { fatalError() } + // 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() } @@ -204,19 +204,38 @@ public struct TestInStruct { // 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) && $OptionalIsolatedParameters && $ExpressionMacroDefaultArguments -// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults -// CHECK-NEXT: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) -// CHECK-NEXT: @backDeployed(before: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999) -// CHECK-NEXT: @inlinable public func withCheckedContinuation(isolation: -@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) -@backDeployed(before: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999) +// CHECK-LABEL: #if compiler(>=5.3) && $OptionalIsolatedParameters && $ExpressionMacroDefaultArguments // Suppression Count: 24 +// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 25 +// CHECK-NEXT: @inlinable public func withCheckedContinuation(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation) -> Swift.Void) async -> sending T { +// CHECK-NEXT: fatalError() +// CHECK-NEXT: } +// CHECK-NEXT: #else +// CHECK-NEXT: @inlinable public func withCheckedContinuation(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation) -> Swift.Void) async -> T { +// CHECK-NEXT: fatalError() +// CHECK-NEXT: } +// CHECK-NEXT: #endif +// CHECK-NEXT: #endif @inlinable public func withCheckedContinuation( isolation: isolated (any _Concurrency.Actor)? = #isolation, function: String = #function, _ body: (_Concurrency.CheckedContinuation) -> Swift.Void ) async -> sending T { - return await withUnsafeContinuation { - body(CheckedContinuation(continuation: $0, function: function)) - } + fatalError() } + +// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 26 +// CHECK-NEXT: public var publicGlobal: (sending test.NonSendableKlass) -> () +// CHECK-NEXT: #else +// CHECK-NEXT: public var publicGlobal: (test.NonSendableKlass) -> () +// CHECK-NEXT: #endif +public var publicGlobal: (sending NonSendableKlass) -> () = { x in fatalError() } + +// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 27 +// CHECK-NEXT: @usableFromInline +// CHECK-NEXT: internal var usableFromInlineGlobal: (sending test.NonSendableKlass) -> () +// CHECK-NEXT: #else +// CHECK-NEXT: @usableFromInline +// CHECK-NEXT: internal var usableFromInlineGlobal: (test.NonSendableKlass) -> () +// CHECK-NEXT: #endif +@usableFromInline +internal var usableFromInlineGlobal: (sending NonSendableKlass) -> () = { x in fatalError() } From af82326855b5109e604fa8dce731d14fb28c201f Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Fri, 31 May 2024 10:01:59 -0700 Subject: [PATCH 7/7] Mark an -Xllvm flag with -Xllvm... --- test/Concurrency/sending_conditional_suppression.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Concurrency/sending_conditional_suppression.swift b/test/Concurrency/sending_conditional_suppression.swift index 7a72efda208fd..da80ca79785f3 100644 --- a/test/Concurrency/sending_conditional_suppression.swift +++ b/test/Concurrency/sending_conditional_suppression.swift @@ -1,6 +1,6 @@ // 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 - -disable-availability-checking -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 - -disable-availability-checking -Xllvm -swift-ast-printer-number-suppression-checks %s | %FileCheck %s // REQUIRES: asserts