mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[expand-placeholder] Add support for multiple-trailing closures
Since placeholder expansion works with a single placeholder, which is
somewhat at odds with multiple-trailing closures, we eagerly attempt to
expand all consecutive placeholders of closure type. That is, if the API
has multiple closure parameters at the end, expanding any one of them
will transform all of them to the new syntax.
Example
```
foo(a: <#T##()->()#>, b: <#T##()->()#>)
```
expanding *either* parameter will produce the following:
```
foo {
<#code#>
} b: {
<#code#>
}
```
(caveat: the indentation is not part of placeholder expansion, but it's
added here for clarity)
At least for now we do not attempt to corral an existing closure into
the new syntax, so for
```
foo(a: { bar() }, b: <#T##()->()#>)
```
The exansion will be
```
foo(a: { bar() }) {
<#code#>
}
```
as it was before.
rdar://59688632
This commit is contained in:
committed by
John McCall
parent
feaaf39206
commit
2bf014dc74
@@ -67,43 +67,42 @@ func f1() {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// FIXME: whether we get a trailing closure or not depends on the order we
|
||||
// expand the placeholders.
|
||||
func f1() {
|
||||
bar(<#T##__skip__: () -> ()##() -> ()#>, <#T##d: () -> ()##() -> ()#>)
|
||||
}
|
||||
// CHECK: bar(<#T##__skip__: () -> ()##() -> ()#>, {
|
||||
// CHECK: bar {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: })
|
||||
// CHECK-NEXT: } _: {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }
|
||||
|
||||
func f1() {
|
||||
bar(<#T##d: () -> ()##() -> ()#>, <#T##d: () -> ()##() -> ()#>)
|
||||
}
|
||||
// CHECK: bar({
|
||||
// CHECK: bar {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }) {
|
||||
// CHECK-NEXT: } _: {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// FIXME: whether we get a trailing closure or not depends on the order we
|
||||
// expand the placeholders.
|
||||
func f1() {
|
||||
bar(a : <#T##__skip__: () -> ()##() -> ()#>, b : <#T##d: () -> ()##() -> ()#>)
|
||||
}
|
||||
// CHECK: bar(a : <#T##__skip__: () -> ()##() -> ()#>, b : {
|
||||
// CHECK: bar {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: })
|
||||
// CHECK-NEXT: } b: {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }
|
||||
|
||||
func f1() {
|
||||
bar(a : <#T##d: () -> ()##() -> ()#>, b : <#T##d: () -> ()##() -> ()#>)
|
||||
}
|
||||
// CHECK: bar(a : {
|
||||
// CHECK: bar {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }) {
|
||||
// CHECK-NEXT: } b: {
|
||||
// CHECK-NEXT: <#code#>
|
||||
// CHECK-NEXT: }
|
||||
|
||||
|
||||
func f1() {
|
||||
bar(a : {}}, <#T##d: () -> ()##() -> ()#>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user