You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Function builders] Add Fix-Its for missing build* members in builders.
When a use of a function builder involves a statement kind that the
function builder doesn't support (e.g., if-else), add a note to the
diagnostic that specifies what methods need to be added to the
function builder to support that statement, including Fix-Its with
stub implementations.
// expected-note@-1{{add 'buildOptional(_:)' to the function builder 'TupleBuilderWithoutIf' to add support for 'if' statements without an 'else'}}{{31-31=\n static func buildOptional(_ component: <#Component#>?) -> <#Component#> {\n <#code#>\n \}}}
50
+
// expected-note@-2{{add 'buildEither(first:)' and `buildEither(second:)' to the function builder 'TupleBuilderWithoutIf' to add support for 'if'-'else' and 'switch'}}{{31-31=\n static func buildEither(first component: <#Component#>) -> <#Component#> {\n <#code#>\n \}\n\n static func buildEither(second component: <#Component#>) -> <#Component#> {\n <#code#>\n \}}}
51
+
// expected-note@-3{{add 'buildArray(_:)' to the function builder 'TupleBuilderWithoutIf' to add support for 'for'..'in' loops}}{{31-31=\n static func buildArray(_ components: [<#Component#>]) -> <#Component#> {\n <#code#>\n \}}}
49
52
staticfunc buildBlock()->(){}
50
53
51
54
staticfunc buildBlock<T1>(_ t1:T1)->T1{
@@ -106,6 +109,19 @@ func testDiags() {
106
109
"hello"
107
110
}
108
111
}
112
+
113
+
tuplifyWithoutIf(true){
114
+
if $0 { // expected-error{{closure containing control flow statement cannot be used with function builder 'TupleBuilderWithoutIf'}}
115
+
"hello"
116
+
}else{
117
+
}
118
+
}
119
+
120
+
tuplifyWithoutIf(true){ a in
121
+
forxin0..<100{ // expected-error{{closure containing control flow statement cannot be used with function builder 'TupleBuilderWithoutIf'}}
0 commit comments