Skip to content

[ChangeLog] Add an entry describing new behavior when passing type na… #37262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
Swift 5.5
---------

* Type names are no longer allowed as an argument to a subscript parameter that expects a metatype type

```swift
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, @xedin, would you mind indenting these lines so that all of the text falls under the bullet point in the formatted document?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct MyValue {
}

struct MyStruct {
subscript(a: MyValue.Type) -> Int { get { ... } }
}

func test(obj: MyStruct) {
let _ = obj[MyValue]
}
```

Accepting subscripts with `MyValue` as an argument was an oversight because `MyValue` requires explicit `.self`
to reference its metatype, so correct syntax would be to use `obj[MyValue.self]`.

* [SE-0310][]:

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:
Expand Down Expand Up @@ -49,7 +67,6 @@ Swift 5.5
}
```


* [SE-0306][]:

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:
Expand Down