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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name execution_attr
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name execution_attr
// RUN: %FileCheck %s --input-file %t.swiftinterface
// REQUIRES: concurrency
public struct TestWithAttrs {
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: public func test(_: nonisolated(nonsending) @escaping () async -> Swift.Void)
// CHECK-NEXT: #endif
public func test(_: nonisolated(nonsending) @escaping () async -> Void) {}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: public func withInOut(fn: nonisolated(nonsending) inout () async -> Swift.Void)
// CHECK-NEXT: #endif
public func withInOut(fn: nonisolated(nonsending) inout () async -> Void) {}
}
public struct Test {
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: nonisolated(nonsending) public init() async
// CHECK-NEXT: #endif
nonisolated(nonsending)
public init() async {
}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: @concurrent public init(something: Swift.Int) async
// CHECK-NEXT: #endif
@concurrent
public init(something: Int) async {
}
// CHECK-NOT: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK: public init(noExplicit: Swift.String) async
// CHECK-NOT: #endif
public init(noExplicit: String) async {
}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: @concurrent public func test() async
// CHECK-NEXT: #endif
@concurrent
public func test() async {
}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: public func other(_: nonisolated(nonsending) () async -> Swift.Void)
// CHECK-NEXT: #endif
public func other(_: nonisolated(nonsending) () async -> Void) {}
// CHECK-NOT: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK: public func concurrentResult(_: () async -> Swift.Void) -> (Swift.Int) async -> Swift.Void
// CHECK-NOT: #endif
public func concurrentResult(_: () async -> Void) -> @concurrent (Int) async -> Void {}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: public func nestedPositions1(_: Swift.Array<[Swift.String : nonisolated(nonsending) (Swift.Int) async -> Swift.Void]>)
// CHECK-NEXT: #endif
public func nestedPositions1(_: Array<[String: nonisolated(nonsending) (Int) async -> Void]>) {}
// CHECK-NOT: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK: public func nestedPositions2(_: Swift.Array<[Swift.String : (Swift.Int) async -> Swift.Void]>)
// CHECK-NOT: #endif
public func nestedPositions2(_: Array<[String: @concurrent (Int) async -> Void]>) {}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: nonisolated(nonsending) public var testOnVar: Swift.Int {
// CHECK-NEXT: get async
// CHECK-NEXT: }
// CHECK-NEXT: #endif
nonisolated(nonsending)
public var testOnVar: Int {
get async {
42
}
}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: @concurrent public var testOnVarConcurrent: Swift.Int {
// CHECK-NEXT: get async
// CHECK-NEXT: }
// CHECK-NEXT: #endif
@concurrent
public var testOnVarConcurrent: Int {
get async {
42
}
}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: nonisolated(nonsending) public subscript(onSubscript _: Swift.Int) -> Swift.Bool {
// CHECK-NEXT: get async
// CHECK-NEXT: }
// CHECK-NEXT: #endif
nonisolated(nonsending)
public subscript(onSubscript _: Int) -> Bool {
get async {
false
}
}
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
// CHECK-NEXT: @concurrent public subscript(concurrentOnSubscript _: Swift.Int) -> Swift.Bool {
// CHECK-NEXT: get async
// CHECK-NEXT: }
// CHECK-NEXT: #endif
@concurrent
public subscript(concurrentOnSubscript _: Int) -> Bool {
get async {
false
}
}
}
|