We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
callAsFunction
1 parent 8dcd1c6 commit 4cb7ebfCopy full SHA for 4cb7ebf
test/Sema/call_as_function_optional.swift
@@ -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
13
14
+}
15
+func testOptional<T>(_ x: T?) {
16
+ _ = x()()()
17
+ // Test trailing closure syntax.
18
+ _ = x { _ in } ({ _ in })
19
0 commit comments