-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Strong mode and dart:core's "Function" #27457
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
|
Thanks for the background. |
I'm closing as a duplicate of dart-lang/test#436 |
I forget where we left this exactly - is it possible to make this work without inference by requiring explicit instantiation? If so, is this high enough priority for us to go through two breaking changes in the API (one to make it usable via explicit instantiation, and one to make it usable via inference if/when we get support for |
We could theoretically define it as Function expectAsync/*<T>*/(Function callback); but that's a pretty heavy burden to impose on users, and is effectively a breaking change in the sense that all existing call sites will need to be modified. I'd really like to avoid any breaking changes in |
Is there an API which would:
It seems like the API you define above is close to that. Non strong users can ignore it, strong mode users could use it via explicit instantiation if they really wanted to. Eventually we could make it We'd discussed the following more complex signature in the other bug: Function/*=F*/ expectAsync/*<T, F extends Function<T>>*/(Function/*=F*/ callback); I think the benefit of this is that you don't have a cast on the output value, is that right? @jmesserly I don't think our existing inference would do the right thing with this more complex signature (I don't think we consider bounds during inference). We should think about whether our constraint solving would generalize to this or whether it would open a big ol can of worms. |
It's close, but it doesn't satisfy the third bullet point: it won't be forwards-compatible with the eventual solution. Which means there'll still be a breaking change coming down the pipe. |
Dumb question: Could we offer a new API to help strong-mode users, i.e. I'd be OK if it's marked with DANGER: This will change and here are the steps* |
Closing again as duplicate of dart-lang/test#436 |
FYI @leafpetersen ... we do consider bounds during inference:
I believe it would work with current inference, but it'd be good to add a test for. |
update: inference seems to work for that, but I found a different bug, which I'll file. |
and that bug is #27458 |
The
Function
interface is used by several packages, such aspackage:test
to be able to declare the input/output is a Function, no matter how many arguments/signature. That's nice. But...I'm getting a "Unsound implicit cast from Function to () -> dynamic".
I'm not sure how to solve this nicely. You can see a reproduction case on Dartpad, or below:
I realize this might not be "strong mode" safe. If so, what is the Future of
Function
?/cc @vsmenon @leafpetersen @nex3
The text was updated successfully, but these errors were encountered: