Skip to content

Commit 4cb7ebf

Browse files
committed
Add Optional callAsFunction test.
1 parent 8dcd1c6 commit 4cb7ebf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// Test extending `Optional` with `func callAsFunction`.
4+
// `Optional` is an edge case since constraint simplification has special
5+
// `Optional` stripping logic.
6+
7+
extension Optional {
8+
func callAsFunction() -> Optional {
9+
return self
10+
}
11+
func callAsFunction(_ fn: (Int) -> Void) -> Optional {
12+
return self
13+
}
14+
}
15+
func testOptional<T>(_ x: T?) {
16+
_ = x()()()
17+
// Test trailing closure syntax.
18+
_ = x { _ in } ({ _ in })
19+
}

0 commit comments

Comments
 (0)