-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onanalyzer-apiIssues that impact the public API of the analyzer packageIssues that impact the public API of the analyzer packagearea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
During my development of https://dart-review.googlesource.com/c/sdk/+/400660, I ran into a bug where ElementLocationImpl.fromElement
is not always correct in assuming that LocalFunctionElementImpl.wrappedElement._enclosingElement3
is always of type ExecutableElementImpl
:
ElementLocationImpl.fromElement(Element2 element) {
List<String> components = <String>[];
Element2? ancestor = element;
while (ancestor != null) {
if (ancestor is! ElementImpl2) {
...
} else {
components.insert(0, ancestor.identifier);
if (ancestor is LocalFunctionElementImpl) {
ancestor = (ancestor.wrappedElement._enclosingElement3
as ExecutableElementImpl)
.element;
} else {
ancestor = ancestor.enclosingElement2;
}
}
}
_components = components.toFixedList();
}
To repro this failure, check out patchset 4 of https://dart-review.googlesource.com/c/sdk/+/400660 and change line 4435 of pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
from this:
new Set.identity();
to this:
{};
Then run the test suite pkg/analyzer/test/generated/invalid_code_test.dart
.
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onanalyzer-apiIssues that impact the public API of the analyzer packageIssues that impact the public API of the analyzer packagearea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)