-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Analyzer summaries do not encode inferred args for constant constructor invocations #32290
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
To fix this, we need to make the following modifications:
*Note that this will need to be done carefully to avoid backward compatibility problems. E.g. you can't just add the slot to the UnlinkedExpr.ints list, because then old and new analyzers will disagree about where they are in the ints array when evaluating a constant. Probably we should just add a new field, UnlinkedExpr.constructorInvocationTypeSlots. |
Change-Id: Ic8513a5ee1fb9de0d3e71a06f85d5bfb60024d1f Reviewed-on: https://dart-review.googlesource.com/43481 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
@stereotype441 @devoncarew Should I assume this will never get fixed due to summaries not sticking around long-term? The hacks I have in to "pretend" to do inference are pretty scary, and I'd hate to have to rely on them longer than we have to. |
Yeah, I think it's safe to assume this won't get fixed until we switch over to using the common front end. :( |
Thanks! |
@bwilkerson @stereotype441 This issue recently came up for a customer during the null safety migration. Considering that the analyzer didn't end up using the CFE, could we look into this again? |
@scheglov, who has taken over the analyzer summary work. |
The test case in the first message already works, probably since about 2020. |
Bug: #32290 Change-Id: Ic4581f0a531a9460f8764e8dd190cc50a19de0f9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323228 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
Perhaps the test case here was fixed, but I believe we're still able to reproduce the issue with a more complex example. Please see the internal issue for a reproduction. |
What makes you think that there is still an issue in the analyzer? |
I think I figured out the issue. The code in question looked like: const tokenA = OpaqueToken<List<A>>();
const tokenB = OpaqueToken<List<B>>();
List<A> createListA() => ...;
List<B> createListB() => ...;
const provider = [
FactoryProvider.forToken(tokenA, createListA),
FactoryProvider.forToken(tokenB, createListB),
]; It's important to note the type signature of class FactoryProvider<T extends Object> implements Provider<T> {
FactoryProvider.forToken(OpaqueToken<T> token, Function useFactory) { ... }
} In our compiler, we were first trying to infer the type of each provider its type In practice we should probably be preferring the type of the token itself, over the type returned from inference. If this sounds like it's working as expected then feel free to close. |
Consider the following code:
Type inference infers that the constant constructor invocation is
const C<int>(0)
. But this information is not recorded in the summary. Therefore, ifx
is reconstituted from a summary and constant evaluated, and the type ofx
's constant value is queried, the result will beC<dynamic>
.The text was updated successfully, but these errors were encountered: