Skip to content

Commit a2063a8

Browse files
committed
[ChangeLog] Add an entry describing new behavior when passing type name as an argument
1 parent 34b532a commit a2063a8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66
Swift 5.5
77
---------
88

9+
* Type names are no longer allowed as an argument to a subscript parameter that expects a metatype type
10+
11+
```swift
12+
struct MyValue {
13+
}
14+
15+
struct MyStruct {
16+
subscript(a: MyValue.Type) -> Int { get { ... } }
17+
}
18+
19+
func test(obj: MyStruct) {
20+
let _ = obj[MyValue]
21+
}
22+
```
23+
24+
Accepting subscripts with `MyValue` as an argument was an oversight because `MyValue` requires explicit `.self`
25+
to reference its metatype, so correct syntax would be to use `obj[MyValue.self]`.
26+
927
* [SE-0310][]:
1028

1129
Read-only computed properties and subscripts can now define their `get` accessor to be `async` and/or `throws`, by writing one or both of those keywords between the `get` and `{`. Thus, these members can now make asynchronous calls or throw errors in the process of producing a value:
@@ -49,7 +67,6 @@ Swift 5.5
4967
}
5068
```
5169

52-
5370
* [SE-0306][]:
5471

5572
Swift 5.5 includes support for actors, a new kind of type that isolates its instance data to protect it from concurrent access. Accesses to an actor's instance declarations from outside the must be asynchronous:

0 commit comments

Comments
 (0)