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

(...)->void must be a subtype of (...)->dynamic. #27727

Closed
floitschG opened this issue Nov 2, 2016 · 7 comments
Closed

(...)->void must be a subtype of (...)->dynamic. #27727

floitschG opened this issue Nov 2, 2016 · 7 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Milestone

Comments

@floitschG
Copy link
Contributor

Strong mode needs to allow functions that return void when a function that returns dynamic is expected.

Example use case:

T run<T>(T f()) {
  print("running");
  var t = f();
  print("done running");
  return t;
}

void printRunning() { print("running"); }
run<dynamic>(printRunning);

Ideally, we would like to write void in the generic type (or infer it): #27504

While this issue should stand on its own, it decreases the priority of #27504.

@floitschG floitschG added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Nov 2, 2016
@floitschG floitschG added this to the 1.50 milestone Nov 2, 2016
@leafpetersen
Copy link
Member

@bwilkerson @jmesserly There's an analyzer and a DDC component to this, could you each take the respective parts?

@jmesserly jmesserly self-assigned this Nov 7, 2016
@jmesserly
Copy link

jmesserly commented Nov 7, 2016

Yeah I can take a shot at this. Shouldn't be too hard.

edit: and presumably we also want to allow "void" in inference.

@dgrove
Copy link
Contributor

dgrove commented Nov 11, 2016

I'll split this up into analyzer and DDC pieces.

@jmesserly
Copy link

thanks. I don't mind doing both BTW, it's probably pretty simple.

@leafpetersen
Copy link
Member

Status: out for implementation.

@jmesserly
Copy link

Huh. I might be missing something but this seems to be implemented already in Analyzer strong mode.

@jmesserly
Copy link

DDC also appears to work already. I added an Analyzer and DDC test using the code example provided. Tentatively closing, let me know if there was something else we'd like to fix here.

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

4 participants