|
1 | 1 | // RUN: %empty-directory(%t)
|
2 | 2 |
|
3 |
| -// 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 |
| 3 | +// 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 |
| 4 | + |
| 5 | +// REQUIRES: asserts |
4 | 6 |
|
5 | 7 | public class NonSendableKlass {}
|
6 | 8 |
|
@@ -90,4 +92,150 @@ public struct TestInStruct {
|
90 | 92 | // CHECK-NEXT: public func testKlassArgAndResult(_ x: test.NonSendableKlass, _ y: test.NonSendableKlass, z: test.NonSendableKlass) -> test.NonSendableKlass
|
91 | 93 | // CHECK-NEXT: #endif
|
92 | 94 | public func testKlassArgAndResult(_ x: NonSendableKlass, _ y: sending NonSendableKlass, z: NonSendableKlass) -> sending NonSendableKlass { fatalError() }
|
| 95 | + |
| 96 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 97 | + // CHECK-NEXT: public func testFunctionArg(_ x: () -> sending test.NonSendableKlass) |
| 98 | + // CHECK-NEXT: #else |
| 99 | + // CHECK-NEXT: public func testFunctionArg(_ x: () -> test.NonSendableKlass) |
| 100 | + // CHECK-NEXT: #endif |
| 101 | + public func testFunctionArg(_ x: () -> sending NonSendableKlass) { fatalError() } |
| 102 | + |
| 103 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 104 | + // CHECK-NEXT: public func testFunctionResult() -> (() -> sending test.NonSendableKlass) |
| 105 | + // CHECK-NEXT: #else |
| 106 | + // CHECK-NEXT: public func testFunctionResult() -> (() -> test.NonSendableKlass) |
| 107 | + // CHECK-NEXT: #endif |
| 108 | + public func testFunctionResult() -> (() -> sending NonSendableKlass) { fatalError() } |
| 109 | + |
| 110 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 111 | + // CHECK-NEXT: @usableFromInline |
| 112 | + // CHECK-NEXT: internal func testUsableFromInlineKlassArg(_ x: sending test.NonSendableKlass) |
| 113 | + // CHECK-NEXT: #else |
| 114 | + // CHECK-NEXT: @usableFromInline |
| 115 | + // CHECK-NEXT: internal func testUsableFromInlineKlassArg(_ x: test.NonSendableKlass) |
| 116 | + // CHECK-NEXT: #endif |
| 117 | + @usableFromInline func testUsableFromInlineKlassArg(_ x: sending NonSendableKlass) { fatalError() } |
| 118 | + |
| 119 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 120 | + // CHECK-NEXT: @usableFromInline |
| 121 | + // CHECK-NEXT: internal func testUsableFromInlineKlassResult() -> sending test.NonSendableKlass |
| 122 | + // CHECK-NEXT: #else |
| 123 | + // CHECK-NEXT: @usableFromInline |
| 124 | + // CHECK-NEXT: internal func testUsableFromInlineKlassResult() -> test.NonSendableKlass |
| 125 | + // CHECK-NEXT: #endif |
| 126 | + @usableFromInline |
| 127 | + func testUsableFromInlineKlassResult() -> sending NonSendableKlass { fatalError() } |
| 128 | + |
| 129 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 130 | + // CHECK-NEXT: @usableFromInline |
| 131 | + // CHECK-NEXT: internal func testUsableFromInlineKlassArgAndResult(_ x: test.NonSendableKlass, _ y: sending test.NonSendableKlass, z: test.NonSendableKlass) -> sending test.NonSendableKlass |
| 132 | + // CHECK-NEXT: #else |
| 133 | + // CHECK-NEXT: @usableFromInline |
| 134 | + // CHECK-NEXT: internal func testUsableFromInlineKlassArgAndResult(_ x: test.NonSendableKlass, _ y: test.NonSendableKlass, z: test.NonSendableKlass) -> test.NonSendableKlass |
| 135 | + // CHECK-NEXT: #endif |
| 136 | + @usableFromInline |
| 137 | + func testUsableFromInlineKlassArgAndResult(_ x: NonSendableKlass, _ y: sending NonSendableKlass, z: NonSendableKlass) -> sending NonSendableKlass { fatalError() } |
| 138 | + |
| 139 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 140 | + // CHECK-NEXT: @usableFromInline |
| 141 | + // CHECK-NEXT: internal func testUsableFromInlineFunctionArg(_ x: () -> sending test.NonSendableKlass) |
| 142 | + // CHECK-NEXT: #else |
| 143 | + // CHECK-NEXT: @usableFromInline |
| 144 | + // CHECK-NEXT: internal func testUsableFromInlineFunctionArg(_ x: () -> test.NonSendableKlass) |
| 145 | + // CHECK-NEXT: #endif |
| 146 | + @usableFromInline |
| 147 | + func testUsableFromInlineFunctionArg(_ x: () -> sending NonSendableKlass) { fatalError() } |
| 148 | + |
| 149 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 150 | + // CHECK-NEXT: @usableFromInline |
| 151 | + // CHECK-NEXT: internal func testUsableFromInlineFunctionResult() -> (() -> sending test.NonSendableKlass) |
| 152 | + // CHECK-NEXT: #else |
| 153 | + // CHECK-NEXT: @usableFromInline |
| 154 | + // CHECK-NEXT: internal func testUsableFromInlineFunctionResult() -> (() -> test.NonSendableKlass) |
| 155 | + // CHECK-NEXT: #endif |
| 156 | + @usableFromInline |
| 157 | + func testUsableFromInlineFunctionResult() -> (() -> sending NonSendableKlass) { fatalError() } |
| 158 | + |
| 159 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 160 | + // CHECK-NEXT: public var publicVarFieldFunctionArg: (sending test.NonSendableKlass) -> () |
| 161 | + // CHECK-NEXT: #else |
| 162 | + // CHECK-NEXT: public var publicVarFieldFunctionArg: (test.NonSendableKlass) -> () |
| 163 | + // CHECK-NEXT: #endif |
| 164 | + public var publicVarFieldFunctionArg: (sending NonSendableKlass) -> () |
| 165 | + |
| 166 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 167 | + // CHECK-NEXT: @usableFromInline |
| 168 | + // CHECK-NEXT: internal var internalVarFieldFunctionArg: (sending test.NonSendableKlass) -> () |
| 169 | + // CHECK-NEXT: #else |
| 170 | + // CHECK-NEXT: @usableFromInline |
| 171 | + // CHECK-NEXT: internal var internalVarFieldFunctionArg: (test.NonSendableKlass) -> () |
| 172 | + // CHECK-NEXT: #endif |
| 173 | + @usableFromInline |
| 174 | + var internalVarFieldFunctionArg: (sending NonSendableKlass) -> () |
| 175 | + |
| 176 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 177 | + // CHECK-NEXT: public let publicLetFieldFunctionArg: (sending test.NonSendableKlass) -> () |
| 178 | + // CHECK-NEXT: #else |
| 179 | + // CHECK-NEXT: public let publicLetFieldFunctionArg: (test.NonSendableKlass) -> () |
| 180 | + // CHECK-NEXT: #endif |
| 181 | + public let publicLetFieldFunctionArg: (sending NonSendableKlass) -> () |
| 182 | + |
| 183 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 184 | + // CHECK-NEXT: @usableFromInline |
| 185 | + // CHECK-NEXT: internal let internalLetFieldFunctionArg: (sending test.NonSendableKlass) -> () |
| 186 | + // CHECK-NEXT: #else |
| 187 | + // CHECK-NEXT: @usableFromInline |
| 188 | + // CHECK-NEXT: internal let internalLetFieldFunctionArg: (test.NonSendableKlass) -> () |
| 189 | + // CHECK-NEXT: #endif |
| 190 | + @usableFromInline |
| 191 | + let internalLetFieldFunctionArg: (sending NonSendableKlass) -> () |
| 192 | + |
| 193 | + // CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults |
| 194 | + // CHECK-NEXT: @usableFromInline |
| 195 | + // CHECK-NEXT: internal init(_ x: Swift.Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass) |
| 196 | + // CHECK-NEXT: #else |
| 197 | + // CHECK-NEXT: @usableFromInline |
| 198 | + // CHECK-NEXT: internal init(_ x: Swift.Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass) |
| 199 | + // CHECK-NEXT: #endif |
| 200 | + @usableFromInline |
| 201 | + internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending NonSendableKlass) { fatalError() } |
93 | 202 | }
|
| 203 | + |
| 204 | +// Make sure that we emit compiler(>= 5.3) when emitting the suppressing check |
| 205 | +// to make sure we do not fail if we fail to parse sending in the if block. |
| 206 | + |
| 207 | +// CHECK-LABEL: #if compiler(>=5.3) && $OptionalIsolatedParameters && $ExpressionMacroDefaultArguments // Suppression Count: 24 |
| 208 | +// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 25 |
| 209 | +// 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 { |
| 210 | +// CHECK-NEXT: fatalError() |
| 211 | +// CHECK-NEXT: } |
| 212 | +// CHECK-NEXT: #else |
| 213 | +// 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 { |
| 214 | +// CHECK-NEXT: fatalError() |
| 215 | +// CHECK-NEXT: } |
| 216 | +// CHECK-NEXT: #endif |
| 217 | +// CHECK-NEXT: #endif |
| 218 | +@inlinable public func withCheckedContinuation<T>( |
| 219 | + isolation: isolated (any _Concurrency.Actor)? = #isolation, |
| 220 | + function: String = #function, |
| 221 | + _ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void |
| 222 | +) async -> sending T { |
| 223 | + fatalError() |
| 224 | +} |
| 225 | + |
| 226 | +// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 26 |
| 227 | +// CHECK-NEXT: public var publicGlobal: (sending test.NonSendableKlass) -> () |
| 228 | +// CHECK-NEXT: #else |
| 229 | +// CHECK-NEXT: public var publicGlobal: (test.NonSendableKlass) -> () |
| 230 | +// CHECK-NEXT: #endif |
| 231 | +public var publicGlobal: (sending NonSendableKlass) -> () = { x in fatalError() } |
| 232 | + |
| 233 | +// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 27 |
| 234 | +// CHECK-NEXT: @usableFromInline |
| 235 | +// CHECK-NEXT: internal var usableFromInlineGlobal: (sending test.NonSendableKlass) -> () |
| 236 | +// CHECK-NEXT: #else |
| 237 | +// CHECK-NEXT: @usableFromInline |
| 238 | +// CHECK-NEXT: internal var usableFromInlineGlobal: (test.NonSendableKlass) -> () |
| 239 | +// CHECK-NEXT: #endif |
| 240 | +@usableFromInline |
| 241 | +internal var usableFromInlineGlobal: (sending NonSendableKlass) -> () = { x in fatalError() } |
0 commit comments