-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Incorrect type inference when swapping type parameters in a constructor call #26990
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
Comments
good catch! it looks like an incorrect capture bug. I wonder if we have a similar bug with generic functions. We certainly tried very hard to avoid this class of bug in them :) If not, there's a few possibilities on what could be going on. Constructors have some notable differences:
Anyway I'll dig in, but that's kind of a scary bug. Hopefully it's something little and not "omg this implementation is fundamentally broken" :) |
Couldn't reproduce this with generic functions, so it seems specific to constructors (which makes sense) |
got it. Our substitution for the "extends" clause w/ recursive bounds was incorrectly affecting inference for this. Fix on the way |
Possibly related: https://codereview.chromium.org/2376213003 |
…e arguments. There is internal code like the added test, which caused us to use out of scope type parameter during inferred type computation. Possibly related issues. #26990 #27072 [email protected], [email protected], [email protected] BUG= Review URL: https://codereview.chromium.org/2376213003 .
…e arguments. There is internal code like the added test, which caused us to use out of scope type parameter during inferred type computation. Possibly related issues. #26990 #27072 [email protected], [email protected], [email protected] BUG= Review URL: https://codereview.chromium.org/2376213003 .
The following code (inspired by HashBiMap.inverse from https://github.com/google/quiver-dart/blob/master/lib/src/collection/bimap.dart) produces strong mode errors:
The errors are:
new Pair(u, t)
:The return type 'Pair<U, U>' is not a 'Pair<U, T>', as defined by the method 'reversed'.
t
innew Pair(u, t)
:The argument type 'T' cannot be assigned to the parameter type 'U'.
It seems like incorrect type parameters are being inferred for the call to the
Pair
constructor.This behavior started happening in 8d2c6d0.
The text was updated successfully, but these errors were encountered: