-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Future.then((value) {}) does not have a type. #27088
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
by "propagated type" did you mean the inferred static type? |
a type :-) |
ah gotcha. Yeah I think this was related to the fix for #25944. What happens now is the return type of the (The reason it's so tricky is we don't want our |
Analyzer tried adding union types at one point as an experiment, but the confusion it caused users more than offset any value we got for it. If we're only using this for a very limited (and local) form of inference and if we're being really careful about how we're reporting errors to the user, then we might be able to avoid the problems we ran into earlier, but we need to tread very carefully. |
hah, yeah that was exactly our fear. So far we've made sure these types aren't user-visible, we always pick one or the other before we'd report anything about them (impl details: it only exists inside InferenceContext). |
fwiw, I think I can fix this bug without any user-visible side effects. |
Another test case related to import 'dart:async';
main() {
var fff = foo().then((_) => 2.3);
}
Future<int> foo() async => 1; I'd expect that the static type of |
strange. I would expect at least |
I've updated my comment. You're right, it's |
Definitely not right :) We used to say the signature of |
@jmesserly @scheglov Do we consider this a regression? Or a crazy gnarly issue? Just want to be super clear if it's a CC @mit-mit |
It breaks rolling |
yeah it's a regression |
I'm almost ready to send a CL out |
Oh wow, I just discovered why this regression happened ... we had a test for it, but there's more than one mock SDK for Analyzer tests. I'd updated one of them without discovering the other, so the test didn't catch the change in Future.then's signature =( |
There are three classes named MockSdk (spread across three of our projects; primarily because it's hard to share test support code) and AnalysisContextFactory creates yet another mock SDK. Which one was updated? |
AnalysisContextFactory was the problematic one. Here's the fix: https://codereview.chromium.org/2253923002/ I don't generally work outside package:analyzer so if the other ones are outside of it, I didn't see them. Suggestion: move mock_sdk under lib/src so other pkgs can use it. |
Yep. I think that's the pattern we agreed on, it's just not been high enough priority to actually get done yet. So far we've been putting this kind of code in |
@bwilkerson since these are all in the SDK repo, could we just create a |
We could, and we discussed that possibility, but we decided it was better for the test support to be carried along with the analyzer package (less chance of it getting out of sync, and better access to internal code). |
@jmesserly @leafpetersen
Test case:
We know the type of
a.getItems()
, but later in(items) => items.length
the type ofitems
is not set.Is it the same as #25944 ?
The text was updated successfully, but these errors were encountered: