Skip to content

Make CanonicalizedMap.cast use the public key and value types - #1008

Open
hamed75kazemii wants to merge 1 commit into
dart-lang:mainfrom
hamed75kazemii:fix-canonicalized-map-cast
Open

hamed75kazemii wants to merge 1 commit into
dart-lang:mainfrom
hamed75kazemii:fix-canonicalized-map-cast

Conversation

@hamed75kazemii

Copy link
Copy Markdown

Summary

  • CanonicalizedMap.cast forwarded to the private map, whose values are MapEntrys and whose keys are the canonical form.
  • A cast such as cast<String, String>() then threw when the entry was read as a key.
  • The cast now goes through Map.castFrom on the public Map<K, V> view.

Fixes #629

Test plan

  • cast<String, String>() on a case-insensitive map returns the original values for both the stored key and its canonical form
  • dart test test/canonicalized_map_test.dart in pkgs/collection

Made with Cursor

The previous implementation cast the internal map of canonical keys and MapEntry values, so a same-type cast threw when the entry was read back as a key.

Fixes dart-lang#629

Co-authored-by: Cursor <cursoragent@cursor.com>
@google-cla

google-cla Bot commented Oct 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CanonicalizedMap.cast() throws _CastError

1 participant