Skip to content

Commit 8cec6b5

Browse files
committed
[Function builders] Add tests for function builders on protocol requirements
1 parent 5d9d4f9 commit 8cec6b5

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/ModuleInterface/function_builders.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ public struct UsesBuilderProperty {
4747
// CHECK: public func myFunc(@FunctionBuilders.TupleBuilder fn: () -> ())
4848
public func myFunc(@TupleBuilder fn: () -> ()) {}
4949
}
50+
51+
public protocol ProtocolWithBuilderProperty {
52+
associatedtype Assoc
53+
54+
// CHECK: @FunctionBuilders.TupleBuilder var myVar: Self.Assoc { get }
55+
@TupleBuilder var myVar: Assoc { get }
56+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

Comments
 (0)