Skip to content

Commit 9022437

Browse files
authored
[Changelog] Add SE-0253: func callAsFunction. (#26866)
Changelog entry for SE-0253. Follow-up to implementation: #24299.
1 parent 95132fd commit 9022437

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SE-0253][]:
30+
31+
Values of types that declare `func callAsFunction` methods can be called
32+
like functions. The call syntax is shorthand for applying
33+
`func callAsFunction` methods.
34+
35+
```swift
36+
struct Adder {
37+
var base: Int
38+
func callAsFunction(_ x: Int) -> Int {
39+
return x + base
40+
}
41+
}
42+
var adder = Adder(base: 3)
43+
adder(10) // returns 13, same as `adder.callAsFunction(10)`
44+
```
45+
46+
* `func callAsFunction` argument labels are required at call sites.
47+
* Multiple `func callAsFunction` methods on a single type are supported.
48+
* `mutating func callAsFunction` is supported.
49+
* `func callAsFunction` works with `throws` and `rethrows`.
50+
* `func callAsFunction` works with trailing closures.
51+
2952
* [SR-4206][]:
3053

3154
A method override is no longer allowed to have a generic signature with
@@ -7711,6 +7734,7 @@ Swift 1.0
77117734
[SE-0244]: <https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md>
77127735
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
77137736
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
7737+
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
77147738
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
77157739

77167740
[SR-106]: <https://bugs.swift.org/browse/SR-106>

0 commit comments

Comments
 (0)