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 of upper bound does not work inside closures #27725

Closed
jmesserly opened this issue Nov 2, 2016 · 3 comments
Closed

type promotion of upper bound does not work inside closures #27725

jmesserly opened this issue Nov 2, 2016 · 3 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@jmesserly
Copy link

Consider this example:

void f/*<T extends num>*/(T x, T y) {
  var f = () => x;
  f = () => y;
  if (x is int) {
    var q = x;

    // BUG HERE
    // This does not capture the type `T extends int`. Instead the return type
    // is `T extends num`. What happens is we substitute {T/T} on the function
    // type, and the way it is implemented, this leads back to `T extends num`.
    var g = () => x;
    g = f;
    /*info:DYNAMIC_INVOKE*/g()./*error:UNDEFINED_GETTER*/isEven;
    q = /*warning:DOWN_CAST_COMPOSITE*/g();
    int r = x;
  }
}

The substitution does not happen correctly here. Note the lazy substitution is also unnecessary when it's just {T/T}.

@jmesserly jmesserly added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-strong-mode type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 2, 2016
@jmesserly
Copy link
Author

this is a loose end from the fix to #27040

@bwilkerson bwilkerson added the P2 A bug or feature request we're likely to work on label Nov 3, 2016
@jmesserly jmesserly assigned jmesserly and unassigned jmesserly Jan 24, 2017
@jmesserly jmesserly self-assigned this Mar 10, 2017
@jmesserly
Copy link
Author

jmesserly commented Mar 10, 2017

I think this will be fixed in https://codereview.chromium.org/2456803004/
(I'm currently updating the test because it's working now.)

@jmesserly
Copy link
Author

This was indeed fixed in f021a70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants