Skip to content

Fix message channel usage in few tests. #14557

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
Feb 8, 2018

Conversation

mraleph
Copy link
Member

@mraleph mraleph commented Feb 8, 2018

Channels don't preserve Map and List type arguments: Map<String, Object>
arrives as Map<dynamic, dynamic> to the receiver.

In Dart 2 type system dynamic no longer serves as bottom type so
Map<dynamic, dynamic> can't be assign to a variable of type
Map<String, dynamic>.

Issue #14556

Channels don't preserve Map and List type arguments: Map<String, Object>
arrives as Map<dynamic, dynamic> to the receiver.

In Dart 2 type system dynamic no longer serves as bottom type so
Map<dynamic, dynamic> can't be assign to a variable of type
Map<String, dynamic>.

Issue flutter#14556
@amirh
Copy link
Contributor

amirh commented Feb 8, 2018

LGTM

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@Hixie
Copy link
Contributor

Hixie commented Feb 8, 2018

Can we preserve the types somehow?

@mraleph
Copy link
Member Author

mraleph commented Feb 8, 2018

Depends on the level of preservation we want to achieve - we need to be predictable.

Some types are easy to preserve, e.g.Map<String, dynamic>, while arbitrary user defined types are harder. So there is a question of how do we achieve predictability so that users know precisely which types pass through channels preserved and which do not.

Once we decide on a set of types to preserve another question becomes: how to write that in Dart without mirrors. Writing code like this in the serializer:

if (x is Map<String, int>) {
} else if (x is Map<int, String>) {
} else if (x is Map<int, int>) {
} else if (x is Map<int, List>) {
} else ...

is not exactly, ahm, pleasant.

I do think that we might want to make channels more strongly typed in the end, but it requires considerable design and engineering effort.

@Hixie
Copy link
Contributor

Hixie commented Feb 8, 2018

The API has a fixed set of types it supports, right? It's not arbitrary types. So at least it would be bounded.

I guess there's no way to construct a Map from Type objects, which is what we'd really need to keep this sane...

@mraleph
Copy link
Member Author

mraleph commented Feb 8, 2018

@Hixie it's not really bounded because types can be nested, e.g. Map<int, Map<String, Map<double, List<Map<dynamic, String>>>>> is a possible type :)

I guess there's no way to construct a Map from Type objects, which is what we'd really need to keep this sane...

Exactly. Also you might want to be able to construct types from other types to create arbitrary nested types like the one I showed above.

@Hixie
Copy link
Contributor

Hixie commented Feb 8, 2018

Fair enough. We should consider this feedback for a feature request for Dart. (Let me know if you'd like me to file the bug, or if you want to file it, add a link to it here. Thanks!)

@mraleph
Copy link
Member Author

mraleph commented Feb 8, 2018

I will take a stub at filing a bug. I will link it to #14556 when I do.

@mraleph mraleph merged commit 7db0564 into flutter:master Feb 8, 2018
@mraleph mraleph deleted the fix-channel-usage branch February 9, 2018 08:55
srawlins added a commit to srawlins/flutter that referenced this pull request Feb 9, 2018
* master: (88 commits)
  Upgrade dartdoc to 0.16.0. (flutter#14602)
  Reduce noise in xcodebuild stdout (flutter#14586)
  Add annotations to ignore analyzer errors on pre-dev.22 SDKs (flutter#14599)
  Roll engine to 337764e (flutter#14597)
  Roll engine with rolled dart (flutter#14538)
  Upgrade packages (flutter#14588)
  Change GlobalObjectKey.toString to strip away State<StatefulWidget>. (flutter#14558)
  Disable selection of the Android ARM64 target platform based on the attached device (flutter#14581)
  Add a flutter run option that can override the default target platform (flutter#14537)
  Fix message channel usage in few tests. (flutter#14557)
  Update documentation on how to test flutter_tools (flutter#14567)
  Fix text_style_text.dart to be Dart 2 compliant. (flutter#14559)
  Hide the NDK warning that should never happen with a regexp (flutter#14503)
  Fix iOS build which broke after the change to fuse --strong option into --preview-dart-2.
  Mark run_machine_concurrent_hot_reload as flaky (flutter#14563)
  Fuse --strong into --preview-dart-2 option.
  Partially fix Dart 2 issues in animated_icons.test. (flutter#14531)
  Strong mode fixes in tests (flutter#14520)
  Fix typo.
  Fix issues.
  ...
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
Channels don't preserve Map and List type arguments: Map<String, Object>
arrives as Map<dynamic, dynamic> to the receiver.

In Dart 2 type system dynamic no longer serves as bottom type so
Map<dynamic, dynamic> can't be assign to a variable of type
Map<String, dynamic>.

Issue flutter#14556
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants