Skip to content

Commit 47b5e6d

Browse files
authored
[ChangeLog] Add an entry describing new behavior when passing type name as an argument (swiftlang#37288)
(cherry picked from commit a2063a8)
1 parent 4dc7250 commit 47b5e6d

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
@@ -29,6 +29,24 @@ CHANGELOG
2929
Swift 5.5
3030
---------
3131

32+
* Type names are no longer allowed as an argument to a subscript parameter that expects a metatype type
33+
34+
```swift
35+
struct MyValue {
36+
}
37+
38+
struct MyStruct {
39+
subscript(a: MyValue.Type) -> Int { get { ... } }
40+
}
41+
42+
func test(obj: MyStruct) {
43+
let _ = obj[MyValue]
44+
}
45+
```
46+
47+
Accepting subscripts with `MyValue` as an argument was an oversight because `MyValue` requires explicit `.self`
48+
to reference its metatype, so correct syntax would be to use `obj[MyValue.self]`.
49+
3250
* [SE-0310][]:
3351

3452
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:
@@ -72,7 +90,6 @@ Swift 5.5
7290
}
7391
```
7492

75-
7693
* [SE-0306][]:
7794

7895
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)