1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -typecheck -enable-library-evolution -parse-as-library -emit-module-interface-path - -module-name MyFile -swift-version 6 | %FileCheck %s
// RUN: %target-swift-frontend %s -typecheck -enable-library-evolution -parse-as-library -emit-module-interface-path - -module-name MyFile -swift-version 6 -module-interface-preserve-types-as-written | %FileCheck -check-prefix=CHECK-REPR %s
// The force printing type reprs option is only available in asserts builds.
// REQUIRES: asserts
// This test validates that when we produce interface files we produce the
// correct interface file for sending when printing normally or with type reprs
// enabled.
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-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
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-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
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-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
@MainActor public var closure: () -> sending NonSendableKlass = { NonSendableKlass() }
|