-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Inline functions parameter type override #30878
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
We took a mis-step here. Our intent is to make Details here: |
Oh okay, that makes sense. So should I type the parameters to |
For |
Making Function(Null) f = (int x) => x + 1;
f(3); // This will fail, because of an implied downcast of `3` to `Null`
(f as Function(int))(3); // This will work
(f as dynamic)(3); // This will work. |
That shows as an unnecessary cast info So is there no "bottom" type that isn't null? Something like "Anything"? Because typing the parameter to Function(Object) f2 = (int x) => x + 1; // warning
f2(3);
(f2 as Function(int))(3);
(f2 as dynamic)(3);
Function(dynamic) f3 = (int x) => x + 1; // info
f3(3);
(f3 as Function(int))(3);
(f3 as dynamic)(3); |
Bug. Filed it here #30897 . |
In Dart 2 I am seeing infos about some typing (
uses_dynamic_as_bottom
) and I don't know how I would get around it.Basically I have something like:
Where A.func is of type
Function(dynamic a)
If I make it
Function(Object a)
then it becomes an error:"A value of type '(int) → Null' can't be assigned to a variable of type 'Function(Object) → dynamic'."
I put together a dartpad of a few things to try and make something work and clarify some rules for myself, but I couldn't find a way to make inline functions like that work.
https://dartpad.dartlang.org/22a4849f9f0d2fcd3813024df252adf0
Thanks!
The text was updated successfully, but these errors were encountered: