This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -957,15 +957,14 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
957957 element.fields = holder.properties.whereType <FieldElement >().toList ();
958958 element.methods = holder.methods;
959959
960- var constructors = holder.constructors;
961- if (constructors.isEmpty) {
962- var containerRef = element.reference! .getChild ('@constructor' );
963- constructors = [
964- ConstructorElementImpl ('' , - 1 )
965- ..isSynthetic = true
966- ..reference = containerRef.getChild ('' ),
967- ];
960+ if (holder.constructors.isEmpty) {
961+ holder.addConstructor (
962+ '' ,
963+ ConstructorElementImpl ('' , - 1 )..isSynthetic = true ,
964+ );
968965 }
966+
967+ var constructors = holder.constructors;
969968 element.constructors = constructors;
970969
971970 // We have all fields and constructors.
Original file line number Diff line number Diff line change @@ -355,6 +355,19 @@ class _ElementWriter {
355355 void _writeConstructorElement (ConstructorElement e) {
356356 e as ConstructorElementImpl ;
357357
358+ // Check that the reference exists, and filled with the element.
359+ var reference = e.reference;
360+ if (reference == null ) {
361+ fail ('Every constructor must have a reference.' );
362+ } else {
363+ var classReference = reference.parent! .parent! ;
364+ // We need this `if` for duplicate declarations.
365+ // The reference might be filled by another declaration.
366+ if (identical (classReference.element, e.enclosingElement)) {
367+ expect (reference.element, same (e));
368+ }
369+ }
370+
358371 _writeIndentedLine (() {
359372 _writeIf (e.isSynthetic, 'synthetic ' );
360373 _writeIf (e.isExternal, 'external ' );
Original file line number Diff line number Diff line change @@ -27,5 +27,5 @@ CHANNEL dev
2727MAJOR 2
2828MINOR 16
2929PATCH 0
30- PRERELEASE 133
30+ PRERELEASE 134
3131PRERELEASE_PATCH 0
You can’t perform that action at this time.
0 commit comments