-
Notifications
You must be signed in to change notification settings - Fork 1.7k
reimplement MapEntry
as a record
#61071
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
base: main
Are you sure you want to change the base?
Conversation
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/439100 Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR). |
Now the record constructor is accessible and named |
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
1 similar comment
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
1 similar comment
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
@mraleph thanks for linking that and tagging @lrhn. This change uses an * the |
It is breaking because it changes runtime semantics: the difference between old and new version is observable via That being said the breakage is probably very limited - |
Good points, I did not consider those things. The original class-based (1, 'hello') is MapEntry<int, String> // used to be false, now true
(1, 'hello') as MapEntry<int, String> // used to throw Error, now it works
f (MapEntry<int, String> e) {
e is Record // used to be false, now true
e is (int, String) // used to be false, now true
} Also agree this changes |
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
1 similar comment
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
keep it backwards compatible by preserving member names and implementing `Object` introduce `asPair` to allow direct usage as a record and `fromPair` to allow direct construction from a record
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
2 similar comments
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/439100 has been updated with the latest commits from this pull request. |
It's not the time, yet. The Dart 3.0 language changes to the platform libraries, including adding That means that pre-3.0 language version libraries can extend Other than that, I don't mind I wouldn't expose But not yet. |
As stated by its documentation,
MapEntry
has been planned to be changed to a value type. This change achieves that by making it aRecord
(K, V)
. Backwards compatibility is mostly achieved by preserving the original API through anextension type
and ensuring itimplements Object
. See #61071 (comment) for what would not be backwards compatibleasPair
is added to the API to allow direct usage as a record, it was required anyways since it is the backing field