Skip to content

Commit 7f02b26

Browse files
dan-zhenglattner
authored andcommitted
[ChangeLog] Add entry for SE-0216. (#20468)
Add changelog entry for SE-0216: user-defined dynamically callable types.
1 parent fbb8eff commit 7f02b26

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ CHANGELOG
2424
Swift 5.0
2525
---------
2626

27+
* [SE-0216][]:
28+
29+
The `@dynamicCallable` attribute enables nominal types to be "callable" via a
30+
simple syntactic sugar. The primary use case is dynamic language
31+
interoperability.
32+
33+
Toy example:
34+
35+
```swift
36+
@dynamicCallable
37+
struct ToyCallable {
38+
func dynamicallyCall(withArguments: [Int]) {}
39+
func dynamicallyCall(withKeywordArguments: KeyValuePairs<String, Int>) {}
40+
}
41+
let x = ToyCallable()
42+
x(1, 2, 3) // desugars to `x.dynamicallyCall(withArguments: [1, 2, 3])`
43+
x(label: 1, 2) // desugars to `x.dynamicallyCall(withKeywordArguments: ["label": 1, "": 2])`
44+
```
45+
2746
* [SR-7251][]:
2847

2948
In Swift 5 mode, attempting to declare a static property with the same name as a

0 commit comments

Comments
 (0)