Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6ac38a9

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
The synthetic default constructor should have reference.
We use ElementImpl.reference to store references to elements. So, all elements must have one, even synthetic. R=brianwilkerson@google.com Change-Id: I29932449d97816108a6c1fca6db3fe7162baa1ce Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99781 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent 92729e0 commit 6ac38a9

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,19 @@ class ClassElementImpl extends AbstractClassElementImpl
560560
}
561561
return ConstructorElementImpl.forLinkedNode(this, reference, node);
562562
}).toList();
563+
564+
if (_constructors.isEmpty) {
565+
return _constructors = [
566+
ConstructorElementImpl.forLinkedNode(
567+
this,
568+
containerRef.getChild(''),
569+
null,
570+
)
571+
..isSynthetic = true
572+
..name = ''
573+
..nameOffset = -1,
574+
];
575+
}
563576
}
564577

565578
if (_unlinkedClass != null) {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@ class LinkingBundleContext {
4646

4747
int indexOfElement(Element element) {
4848
if (element == null) return 0;
49+
assert(element is! Member);
4950

5051
if (identical(element, DynamicElementImpl.instance)) {
5152
return indexOfReference(dynamicReference);
5253
}
5354

54-
if (element is Member) {
55-
element = (element as Member).baseElement;
56-
}
57-
5855
var reference = (element as ElementImpl).reference;
5956
return indexOfReference(reference);
6057
}

0 commit comments

Comments
 (0)