[kernel] Fix crash in dart_scope_calculator when all scopes are artificial

Fixes https://github.com/dart-lang/sdk/issues/55986

Change-Id: Icc7e6dbb4272613e838b0bd2ef9ac4764dd068f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373200
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Jens Johansen 2024-06-26 08:23:59 +00:00 committed by Commit Queue
parent 01cf48f653
commit a8314dac74

View file

@ -633,6 +633,9 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
List<DartScope2> rawScopes, Library library, int offset) { List<DartScope2> rawScopes, Library library, int offset) {
List<DartScope2> firstFilteredScopes = List<DartScope2> firstFilteredScopes =
_filterScopesWithArtificialNodes(rawScopes, library); _filterScopesWithArtificialNodes(rawScopes, library);
if (firstFilteredScopes.isEmpty) {
return rawScopes;
}
if (_allHaveTheSameDefinitions(firstFilteredScopes)) { if (_allHaveTheSameDefinitions(firstFilteredScopes)) {
return [firstFilteredScopes.first]; return [firstFilteredScopes.first];
} }