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

Type promotion could be even better if it analyzed more of the control flow #34483

Closed
Hixie opened this issue Sep 17, 2018 · 3 comments
Closed
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).

Comments

@Hixie
Copy link
Contributor

Hixie commented Sep 17, 2018

This code runs fine (and is provably correct), but the analyzer complains error • The argument type 'dynamic' can't be assigned to the parameter type 'String' • test.dart:8:7 • argument_type_not_assignable:

void bar(String value) {
  print(value.runtimeType);
}

void foo(dynamic value) {
  if (value is! String)
    value = value.toString();
  bar(value);
}

void main() {
  foo(0);
}
@eernstg
Copy link
Member

eernstg commented Sep 17, 2018

Type promotion has been discussed in many issues; I tried to summarize the discussion by adding a list of relevant issues (including this one) to #25565.

@bwilkerson bwilkerson added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Sep 17, 2018
@srawlins
Copy link
Member

I think this is being followed up on at dart-lang/language#80 and dart-lang/language#81

@leafpetersen
Copy link
Member

This works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Projects
None yet
Development

No branches or pull requests

5 participants