Skip to content

Commit 2c674e9

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Consider MultiplyDefinedElement as null for summary serialization.
Bug: https://buganizer.corp.google.com/issues/142145283 Change-Id: I4de873d322236d97fb942dbb0ae3f4fc22a0687e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120440 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent b1db663 commit 2c674e9

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

pkg/analyzer/lib/src/summary2/linking_bundle_context.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class LinkingBundleContext {
5151

5252
int indexOfElement(Element element) {
5353
if (element == null) return 0;
54+
if (element is MultiplyDefinedElement) return 0;
5455
assert(element is! Member);
5556

5657
if (identical(element, DynamicElementImpl.instance)) {

pkg/analyzer/test/src/summary/resynthesize_common.dart

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10867,12 +10867,48 @@ class C {
1086710867

1086810868
test_unresolved_annotation_simpleIdentifier() async {
1086910869
var library = await checkLibrary('@foo class C {}', allowErrors: true);
10870-
checkElementText(library, r'''
10871-
@
10872-
foo/*location: null*/
10870+
checkElementText(
10871+
library,
10872+
r'''
1087310873
class C {
1087410874
}
10875+
metadata
10876+
Annotation
10877+
element: <null>
10878+
name: SimpleIdentifier
10879+
staticElement: <null>
10880+
staticType: dynamic
10881+
token: foo
10882+
''',
10883+
withFullyResolvedAst: true);
10884+
}
10885+
10886+
test_unresolved_annotation_simpleIdentifier_multiplyDefined() async {
10887+
addLibrarySource('/a.dart', 'const v = 0;');
10888+
addLibrarySource('/b.dart', 'const v = 0;');
10889+
var library = await checkLibrary('''
10890+
import 'a.dart';
10891+
import 'b.dart';
10892+
10893+
@v
10894+
class C {}
1087510895
''');
10896+
checkElementText(
10897+
library,
10898+
r'''
10899+
import 'a.dart';
10900+
import 'b.dart';
10901+
class C {
10902+
}
10903+
metadata
10904+
Annotation
10905+
element: <null>
10906+
name: SimpleIdentifier
10907+
staticElement: <null>
10908+
staticType: dynamic
10909+
token: v
10910+
''',
10911+
withFullyResolvedAst: true);
1087610912
}
1087710913

1087810914
test_unresolved_annotation_unnamedConstructorCall_noClass() async {

0 commit comments

Comments
 (0)