mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Function builders] Make sure we contextualize closures with builders applied.
We used to get this contextualization "for free" because closures that had function builders applied to them would get translated into single-expression closures. Now, we need to check for this explicitly.
This commit is contained in:
@@ -352,14 +352,20 @@ func acceptComponentBuilder(@ComponentBuilder _ body: () -> Component) {
|
||||
print(body())
|
||||
}
|
||||
|
||||
func colorWithAutoClosure(_ color: @autoclosure () -> Color) -> Color {
|
||||
return color()
|
||||
}
|
||||
|
||||
var trueValue = true
|
||||
acceptComponentBuilder {
|
||||
"hello"
|
||||
if true {
|
||||
if trueValue {
|
||||
3.14159
|
||||
colorWithAutoClosure(.red)
|
||||
}
|
||||
.red
|
||||
}
|
||||
// CHECK: array([main.Component.string("hello"), main.Component.optional(Optional(main.Component.array([main.Component.floating(3.14159)]))), main.Component.color(main.Color.red)])
|
||||
// CHECK: array([main.Component.string("hello"), main.Component.optional(Optional(main.Component.array([main.Component.floating(3.14159), main.Component.color(main.Color.red)]))), main.Component.color(main.Color.red)])
|
||||
|
||||
// rdar://53325810
|
||||
|
||||
|
||||
Reference in New Issue
Block a user