@@ -139,8 +139,6 @@ class ClassElementLinkedData extends ElementLinkedData<ClassElementImpl> {
139139 element.supertype = reader._readOptionalInterfaceType ();
140140 element.mixins = reader._readInterfaceTypeList ();
141141 element.interfaces = reader._readInterfaceTypeList ();
142- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
143- element.augmentation = reader.readElement () as ClassElementImpl ? ;
144142
145143 if (element.augmentationTarget == null ) {
146144 if (reader.readBool ()) {
@@ -236,8 +234,6 @@ class ConstructorElementLinkedData
236234 element.superConstructor = reader.readElement () as ConstructorElement ? ;
237235 element.redirectedConstructor = reader.readElement () as ConstructorElement ? ;
238236 element.constantInitializers = reader._readNodeList ();
239- element.augmentation = reader.readElement () as ConstructorElementImpl ? ;
240- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
241237 applyConstantOffsets? .perform ();
242238 }
243239}
@@ -372,8 +368,6 @@ class EnumElementLinkedData extends ElementLinkedData<EnumElementImpl> {
372368 element.supertype = reader._readOptionalInterfaceType ();
373369 element.mixins = reader._readInterfaceTypeList ();
374370 element.interfaces = reader._readInterfaceTypeList ();
375- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
376- element.augmentation = reader.readElement () as EnumElementImpl ? ;
377371 if (element.augmentationTarget == null ) {
378372 if (reader.readBool ()) {
379373 var augmented = element.augmentedInternal as AugmentedEnumElementImpl ;
@@ -412,8 +406,6 @@ class ExtensionElementLinkedData
412406 unitElement: element.enclosingElement3,
413407 );
414408 _readTypeParameters (reader, element.typeParameters);
415- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
416- element.augmentation = reader.readElement () as ExtensionElementImpl ? ;
417409 if (element.augmentationTarget == null ) {
418410 var extendedType = reader.readRequiredType ();
419411 if (reader.readBool ()) {
@@ -454,8 +446,6 @@ class ExtensionTypeElementLinkedData
454446 );
455447 _readTypeParameters (reader, element.typeParameters);
456448 element.interfaces = reader._readInterfaceTypeList ();
457- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
458- element.augmentation = reader.readElement () as ExtensionTypeElementImpl ? ;
459449 if (element.augmentationTarget == null ) {
460450 if (reader.readBool ()) {
461451 var augmented =
@@ -500,12 +490,6 @@ class FieldElementLinkedData extends ElementLinkedData<FieldElementImpl> {
500490 element.macroDiagnostics = reader.readMacroDiagnostics ();
501491 element.type = reader.readRequiredType ();
502492
503- var augmentationTarget = reader.readElement () as ElementImpl ? ;
504- element.augmentationTargetAny = augmentationTarget;
505- if (augmentationTarget is FieldElementImpl ) {
506- augmentationTarget.augmentation = element;
507- }
508-
509493 if (element is ConstFieldElementImpl ) {
510494 var initializer = reader._readOptionalExpression ();
511495 if (initializer != null ) {
@@ -541,8 +525,6 @@ class FunctionElementLinkedData extends ElementLinkedData<FunctionElementImpl> {
541525 element.macroDiagnostics = reader.readMacroDiagnostics ();
542526 element.returnType = reader.readRequiredType ();
543527 _readFormalParameters (reader, element.parameters);
544- element.augmentation = reader.readElement () as FunctionElementImpl ? ;
545- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
546528 applyConstantOffsets? .perform ();
547529 }
548530}
@@ -729,6 +711,20 @@ class LibraryReader {
729711 }
730712 }
731713
714+ void _readAugmentationTargetAny <T extends AugmentableElement >(
715+ T nextFragment,
716+ ) {
717+ var augmentationTargetAny = _readOptionalReference ()? .element;
718+ if (augmentationTargetAny is ElementImpl ) {
719+ nextFragment.augmentationTargetAny = augmentationTargetAny;
720+ }
721+
722+ var shouldSetAugmentation = _reader.readBool ();
723+ if (shouldSetAugmentation && augmentationTargetAny is T ) {
724+ augmentationTargetAny.augmentation = nextFragment;
725+ }
726+ }
727+
732728 ClassElementImpl _readClassElement (
733729 CompilationUnitElementImpl unitElement,
734730 Reference unitReference,
@@ -761,8 +757,9 @@ class LibraryReader {
761757 offset: resolutionOffset,
762758 );
763759 element.setLinkedData (reference, linkedData);
764- ClassElementFlags .read (_reader, element);
765760
761+ ClassElementFlags .read (_reader, element);
762+ _readAugmentationTargetAny (element);
766763 element.typeParameters = _readTypeParameters ();
767764
768765 if (! element.isMixinApplication) {
@@ -815,6 +812,7 @@ class LibraryReader {
815812 );
816813 element.setLinkedData (reference, linkedData);
817814 ConstructorElementFlags .read (_reader, element);
815+ _readAugmentationTargetAny (element);
818816 element.parameters = _readParameters ();
819817 return element;
820818 });
@@ -924,8 +922,9 @@ class LibraryReader {
924922 offset: resolutionOffset,
925923 );
926924 element.setLinkedData (reference, linkedData);
927- EnumElementFlags .read (_reader, element);
928925
926+ EnumElementFlags .read (_reader, element);
927+ _readAugmentationTargetAny (element);
929928 element.typeParameters = _readTypeParameters ();
930929
931930 var accessors = < PropertyAccessorElementImpl > [];
@@ -1028,8 +1027,9 @@ class LibraryReader {
10281027 offset: resolutionOffset,
10291028 ),
10301029 );
1031- ExtensionElementFlags .read (_reader, element);
10321030
1031+ ExtensionElementFlags .read (_reader, element);
1032+ _readAugmentationTargetAny (element);
10331033 element.typeParameters = _readTypeParameters ();
10341034
10351035 var accessors = < PropertyAccessorElementImpl > [];
@@ -1088,8 +1088,9 @@ class LibraryReader {
10881088 offset: resolutionOffset,
10891089 ),
10901090 );
1091- ExtensionTypeElementFlags .read (_reader, element);
10921091
1092+ ExtensionTypeElementFlags .read (_reader, element);
1093+ _readAugmentationTargetAny (element);
10931094 element.typeParameters = _readTypeParameters ();
10941095
10951096 var fields = < FieldElementImpl > [];
@@ -1153,6 +1154,7 @@ class LibraryReader {
11531154 element.setLinkedData (reference, linkedData);
11541155
11551156 FieldElementFlags .read (_reader, element);
1157+ _readAugmentationTargetAny (element);
11561158 element.typeInferenceError = _readTopLevelInferenceError ();
11571159
11581160 if (! element.isAugmentation) {
@@ -1226,6 +1228,7 @@ class LibraryReader {
12261228 element.setLinkedData (reference, linkedData);
12271229
12281230 FunctionElementFlags .read (_reader, element);
1231+ _readAugmentationTargetAny (element);
12291232 element.typeParameters = _readTypeParameters ();
12301233 element.parameters = _readParameters ();
12311234
@@ -1354,6 +1357,7 @@ class LibraryReader {
13541357 );
13551358 element.setLinkedData (reference, linkedData);
13561359 MethodElementFlags .read (_reader, element);
1360+ _readAugmentationTargetAny (element);
13571361 element.typeParameters = _readTypeParameters ();
13581362 element.parameters = _readParameters ();
13591363 element.typeInferenceError = _readTopLevelInferenceError ();
@@ -1392,8 +1396,9 @@ class LibraryReader {
13921396 offset: resolutionOffset,
13931397 );
13941398 element.setLinkedData (reference, linkedData);
1395- MixinElementFlags .read (_reader, element);
13961399
1400+ MixinElementFlags .read (_reader, element);
1401+ _readAugmentationTargetAny (element);
13971402 element.typeParameters = _readTypeParameters ();
13981403
13991404 var fields = < FieldElementImpl > [];
@@ -1559,7 +1564,6 @@ class LibraryReader {
15591564
15601565 var element = PropertyAccessorElementImpl (name, - 1 );
15611566 element.name2 = fragmentName;
1562- PropertyAccessorElementFlags .read (_reader, element);
15631567
15641568 var linkedData = PropertyAccessorElementLinkedData (
15651569 reference: reference,
@@ -1569,6 +1573,8 @@ class LibraryReader {
15691573 );
15701574 element.setLinkedData (reference, linkedData);
15711575
1576+ PropertyAccessorElementFlags .read (_reader, element);
1577+ _readAugmentationTargetAny (element);
15721578 element.parameters = _readParameters ();
15731579 return element;
15741580 }
@@ -1696,6 +1702,7 @@ class LibraryReader {
16961702
16971703 element.isConst = isConst;
16981704 TopLevelVariableElementFlags .read (_reader, element);
1705+ _readAugmentationTargetAny (element);
16991706 element.typeInferenceError = _readTopLevelInferenceError ();
17001707
17011708 if (getterReference != null ) {
@@ -1761,6 +1768,7 @@ class LibraryReader {
17611768
17621769 element.isFunctionTypeAliasBased = isFunctionTypeAliasBased;
17631770 TypeAliasElementFlags .read (_reader, element);
1771+ _readAugmentationTargetAny (element);
17641772
17651773 element.typeParameters = _readTypeParameters ();
17661774
@@ -1906,8 +1914,6 @@ class MethodElementLinkedData extends ElementLinkedData<MethodElementImpl> {
19061914 element.macroDiagnostics = reader.readMacroDiagnostics ();
19071915 _readFormalParameters (reader, element.parameters);
19081916 element.returnType = reader.readRequiredType ();
1909- element.augmentation = reader.readElement () as MethodElementImpl ? ;
1910- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
19111917 applyConstantOffsets? .perform ();
19121918 }
19131919}
@@ -1936,8 +1942,6 @@ class MixinElementLinkedData extends ElementLinkedData<MixinElementImpl> {
19361942 element.macroDiagnostics = reader.readMacroDiagnostics ();
19371943 element.superclassConstraints = reader._readInterfaceTypeList ();
19381944 element.interfaces = reader._readInterfaceTypeList ();
1939- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
1940- element.augmentation = reader.readElement () as MixinElementImpl ? ;
19411945
19421946 if (element.augmentationTarget == null ) {
19431947 if (reader.readBool ()) {
@@ -1982,14 +1986,6 @@ class PropertyAccessorElementLinkedData
19821986 element.returnType = reader.readRequiredType ();
19831987 _readFormalParameters (reader, element.parameters);
19841988
1985- var augmentationTarget = reader.readElement () as ElementImpl ? ;
1986- element.augmentationTargetAny = augmentationTarget;
1987- if (augmentationTarget is PropertyAccessorElementImpl ) {
1988- if (augmentationTarget.kind == element.kind) {
1989- augmentationTarget.augmentation = element;
1990- }
1991- }
1992-
19931989 applyConstantOffsets? .perform ();
19941990 }
19951991}
@@ -2620,12 +2616,6 @@ class TopLevelVariableElementLinkedData
26202616 element.macroDiagnostics = reader.readMacroDiagnostics ();
26212617 element.type = reader.readRequiredType ();
26222618
2623- var augmentationTarget = reader.readElement () as ElementImpl ? ;
2624- element.augmentationTargetAny = augmentationTarget;
2625- if (augmentationTarget is TopLevelVariableElementImpl ) {
2626- augmentationTarget.augmentation = element;
2627- }
2628-
26292619 if (element is ConstTopLevelVariableElementImpl ) {
26302620 var initializer = reader._readOptionalExpression ();
26312621 if (initializer != null ) {
@@ -2655,9 +2645,6 @@ class TypeAliasElementLinkedData
26552645
26562646 @override
26572647 void _read (element, reader) {
2658- element.augmentationTargetAny = reader.readElement () as ElementImpl ? ;
2659- element.augmentation = reader.readElement () as TypeAliasElementImpl ? ;
2660-
26612648 element.metadata = reader._readAnnotationList (
26622649 unitElement: unitElement,
26632650 );
0 commit comments