-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Expression.staticParameterElement sometimes points to a synthetic element #48500
Comments
I'm hopeful that this issue will be fixed by a refactor I'm currently in the middle of, so I'm going to assign it to myself for now. If I can't manage to fix it as part of the refactor I'll unassign myself. |
Bug: #48500 Change-Id: I237e44d33cca1d2fe63c205e8bd3dcd775bf079f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235062 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
Moves all of the analyzer's type inference logic for invocations into a single `resolveInvocation` method, defined on an abstract base class `InvocationInferrer`. There are concrete derived classes to specialize this logic for all of the types of AST nodes require this sort of inference (Annotation, ExtensionOverride, FunctionExpressionInvocation, InstanceCreationExpression, MethodInvocation, RedirectingConstructorInvocation, and SuperConstructorInvocation), and the special logic for each node type is slotted into the core algorithm using virtual dispatch. In addition to making the code more maintainable by reducing code duplication, this change paves the way toward modifying the core algorithm to allow inference information to flow between arguments in a generic function call (dart-lang/language#731). Also partially addresses #48500 (Expression.staticParameterElement sometimes points to a synthetic element). Change-Id: I82788d58a62b6555589da16163317b6bbddd53c1 Bug: dart-lang/language#731, #48500 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234864 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
I believe this needs reopening, as I am encountering this issue again on the latest void genericFunction<T>(T bar) {}
void foo() {
genericFunction(1); // IntegerLiteral.staticParameterElement is a `ParameterMember` that points to a synthetic `ParameterElement`
} It still works as expected for generic classes and members though: class C<T> {
C(T bar);
}
void foo() {
C(1); // IntegerLiteral.staticParameterElement is not synthetic
} abstract class C {
T method<T>({arg});
}
test(C c) => c.method<bool>(arg: true); // NamedExpression.staticParameterElement is not synthetic Hopefully this is just a case that was missed in f5af2d9 that can be quickly changed :) |
@abitofevrything Would you mind opening a new issue with this information? A lot has changed in the analyzer since this was implemented and a new issue would allow your issue to be focused on in isolation. Thanks :) |
Created #54669. |
In the following situations,
Expression.staticParameterElement
points to a synthetic element that's not in the element tree (i.e. it has anenclosingElement
that isnull
), whereas I believe it would be possible for it to point to aParameterMember
that in turn points to a parameter element in the element tree:I will shortly land some analyzer unit tests that illustrate this.
The text was updated successfully, but these errors were encountered: