-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Generic inference in function #49884
Comments
Good question! I think this might be a bug in type inference. The inferred type arguments in the invocation of |
The reason type inference isn't filling in According to the spec, horizontal inference decides there's a dependency edge from argument A to argument B if and only if the type of the invocation target is generic, and the following relationship exists among A, B, and at least one of the invocation target’s type parameters T:
There's a little bit of ambiguity here. In condition 2, does a type parameter type count if its bound is a function type? The way I implemented it (in both the analyzer and front end) is that no, a type parameter type whose bound is a function type doesn't count. This is the reason horizontal inference is failing in this example--the We could change that so that a type parameter type was ok if its bound was a function type, but even if we did, since the bound of |
Thanks for the answer. I was waiting for 2.18 and thought type inference would work in that case. Everything turned out to be more difficult ) |
@stereotype441 Should we close this issue as working-as-intended? |
Sure. Closing now. |
Consider the following example:
In the first function (useHandler), the
data
type isdynamic
while in the second function (useHandler2)data
type isint
.Why does type inference not work in the first case?
Dart SDK version: 2.18.0 (stable)
MacOSX
The text was updated successfully, but these errors were encountered: