Skip to content
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

CanonicalizedMap.cast() throws _CastError #230

Open
bobjackman opened this issue Jan 12, 2022 · 0 comments
Open

CanonicalizedMap.cast() throws _CastError #230

bobjackman opened this issue Jan 12, 2022 · 0 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@bobjackman
Copy link

CanonicalizedMap.cast() throws _CastError

Example:

try {
  var sourceMap     = <String, String>{'a': 'A'};
  var canonicalized = new CanonicalizedMap<String, String, String>.from(sourceMap, (String key) => key.toLowerCase());
    
  var badResult     = canonicalized.cast<String, String>();
  var goodResult    = Map.of(canonicalized).cast<String, String>();

  print(goodResult); // {a: A}
  print(badResult ); // _CastError: type 'MapEntry<String, String>' is not a subtype of type 'String' in type cast

} catch(e, s) {
  print('Unhandled Exception: ${e.runtimeType}: $e\n$s');
}

Expected Result:

Calling .cast() should not throw in this circumstance

@lrhn lrhn added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants