Skip to content

Commit 73e0670

Browse files
committed
[TypeChecker] NFC: Add a couple of test-cases for .callAsFunction
Make sure that trailing closure(s) are correctly matched to injected `.callAsFunction` when necessary i.e. constructor doesn't attempt trailing closures but `.callAsFunction` does.
1 parent 1c258ca commit 73e0670

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/Constraints/callAsFunction.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// rdar://83717297
4+
//
5+
// Make sure that trailing closures are matches to the `callAsFunction`
6+
// when used in the same expression as `.init` of a callable type.
7+
8+
protocol View {}
9+
struct EmptyView: View {}
10+
11+
struct MyLayout {
12+
func callAsFunction<V: View>(content: () -> V) -> MyLayout { .init() }
13+
func callAsFunction<V: View>(answer: () -> Int,
14+
content: () -> V) -> MyLayout { .init() }
15+
}
16+
17+
struct Test {
18+
var body1: MyLayout {
19+
MyLayout() {
20+
EmptyView() // Ok
21+
}
22+
}
23+
24+
var body2: MyLayout {
25+
MyLayout() {
26+
42
27+
} content: {
28+
EmptyView() // Ok
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)