-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Callable class has incorrect return type #33194
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
This came up when implementing this https://github.com/escamoteur/get_it |
Here's some info on the mechanism itself: We are working on a specification update to include call method extraction, which is the transformation that takes In your examples, we're relying on Dart 2 inference to give In the first case, In In About the incorrect return type issue: I'm not quite sure how you detect the type of
|
@eernstg Sorry if it seemed like I meant at runtime; it was purely the analysis we had issues with (the tooltips from the analyzer and the lack of code completion). I believe at runtime it's all behaving fine (@escamoteur can confirm though). |
Yes, compiling and runtime is working |
@DanTup, sorry about being so long-winded. ;-) For the run-time behavior it's worth noting that Dart 1 callable objects were full-fledged functions, but with the Dart 2 approach it is a matter of static analysis that some tear-offs of |
tentatlvely assigning to @MichaelRFairhurst |
Quick update on the problem here. It looks like the tooltip shows the free variable type
However, the program itself does not analyze as if
So this is an improvement, but still wrong. Looking into it, but I won't be prioritizing fixing hover or autocomplete. I'll be prioritizing it choosing Object instead of String. I hope that they are the same issue but can't say for sure. |
candidate CL: https://dart-review.googlesource.com/c/sdk/+/64822 |
So it works now? |
The test suggests so, but you'll need a new Dart for it (for standalone Dart SDKs that probably means the next dev release, but for Flutter it might take a little longer to be rolled in). |
Given this code:
a
andc
are typed asString
, butb
is typed asT
(even though no such class exists, and there are no warnings in this code). If I remove theT
as the return type from thecall
method, then the type becomesdynamic
.I presume this should work, but I couldn't find any info on it. I found a couple of open issues about callable classes, but I don't think any are describing this.
Tested with the latest analyzer that's in Flutter master.
The text was updated successfully, but these errors were encountered: