|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %s |
| 3 | +// RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -skip-deinit=false -module-to-print=function_builders -I %t -source-filename=%s | %FileCheck %s |
| 4 | + |
| 5 | +@_functionBuilder |
| 6 | +public struct TupleBuilder { |
| 7 | + public static func buildBlock<T1, T2>(_ t1: T1, _ t2: T2) -> (T1, T2) { |
| 8 | + return (t1, t2) |
| 9 | + } |
| 10 | + |
| 11 | + public static func buildBlock<T1, T2, T3>(_ t1: T1, _ t2: T2, _ t3: T3) |
| 12 | + -> (T1, T2, T3) { |
| 13 | + return (t1, t2, t3) |
| 14 | + } |
| 15 | + |
| 16 | + public static func buildBlock<T1, T2, T3, T4>(_ t1: T1, _ t2: T2, _ t3: T3, _ t4: T4) |
| 17 | + -> (T1, T2, T3, T4) { |
| 18 | + return (t1, t2, t3, t4) |
| 19 | + } |
| 20 | + |
| 21 | + public static func buildBlock<T1, T2, T3, T4, T5>( |
| 22 | + _ t1: T1, _ t2: T2, _ t3: T3, _ t4: T4, _ t5: T5 |
| 23 | + ) -> (T1, T2, T3, T4, T5) { |
| 24 | + return (t1, t2, t3, t4, t5) |
| 25 | + } |
| 26 | + |
| 27 | + public static func buildDo<T>(_ value: T) -> T { return value } |
| 28 | + public static func buildIf<T>(_ value: T?) -> T? { return value } |
| 29 | +} |
| 30 | + |
| 31 | +public protocol ProtocolWithBuilderProperty { |
| 32 | + associatedtype Assoc |
| 33 | + |
| 34 | + // CHECK: @TupleBuilder var myVar: Self.Assoc { get } |
| 35 | + @TupleBuilder var myVar: Assoc { get } |
| 36 | +} |
0 commit comments