@@ -166,6 +166,20 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
166166 return null ;
167167 }
168168
169+ @override
170+ ConstructorElement ? getNamedConstructor (String name) {
171+ if (name == 'new' ) {
172+ // A constructor declared as `C.new` is unnamed, and is modeled as such.
173+ name = '' ;
174+ }
175+ for (ConstructorElement element in constructors) {
176+ if (element.name == name) {
177+ return element;
178+ }
179+ }
180+ return null ;
181+ }
182+
169183 @override
170184 PropertyAccessorElement ? getSetter (String setterName) {
171185 return getSetterFromAccessors (setterName, accessors);
@@ -447,9 +461,6 @@ class ClassElementImpl extends AbstractClassElementImpl {
447461 /// This callback is set during mixins inference to handle reentrant calls.
448462 List <InterfaceType >? Function (ClassElementImpl )? mixinInferenceCallback;
449463
450- /// TODO(scheglov) implement as modifier
451- bool _isSimplyBounded = true ;
452-
453464 ElementLinkedData ? linkedData;
454465
455466 /// Initialize a newly created class element to have the given [name] at the
@@ -661,15 +672,13 @@ class ClassElementImpl extends AbstractClassElementImpl {
661672 setModifier (Modifier .MIXIN_APPLICATION , isMixinApplication);
662673 }
663674
664- /// TODO(scheglov) implement as modifier
665675 @override
666676 bool get isSimplyBounded {
667- return _isSimplyBounded ;
677+ return hasModifier ( Modifier . SIMPLY_BOUNDED ) ;
668678 }
669679
670- /// TODO(scheglov) implement as modifier
671680 set isSimplyBounded (bool isSimplyBounded) {
672- _isSimplyBounded = isSimplyBounded;
681+ setModifier ( Modifier . SIMPLY_BOUNDED , isSimplyBounded) ;
673682 }
674683
675684 @override
@@ -783,10 +792,6 @@ class ClassElementImpl extends AbstractClassElementImpl {
783792 builder.writeClassElement (this );
784793 }
785794
786- @override
787- ConstructorElement ? getNamedConstructor (String name) =>
788- getNamedConstructorFromList (name, constructors);
789-
790795 void setLinkedData (Reference reference, ElementLinkedData linkedData) {
791796 this .reference = reference;
792797 reference.element = this ;
@@ -948,20 +953,6 @@ class ClassElementImpl extends AbstractClassElementImpl {
948953 return implicitConstructor;
949954 }).toList (growable: false );
950955 }
951-
952- static ConstructorElement ? getNamedConstructorFromList (
953- String name, List <ConstructorElement > constructors) {
954- if (name == 'new' ) {
955- // A constructor declared as `C.new` is unnamed, and is modeled as such.
956- name = '' ;
957- }
958- for (ConstructorElement element in constructors) {
959- if (element.name == name) {
960- return element;
961- }
962- }
963- return null ;
964- }
965956}
966957
967958/// A concrete implementation of a [CompilationUnitElement] .
@@ -2749,6 +2740,14 @@ class EnumElementImpl extends AbstractClassElementImpl {
27492740 return _methods;
27502741 }
27512742
2743+ /// Set the methods contained in this class to the given [methods] .
2744+ set methods (List <MethodElement > methods) {
2745+ for (MethodElement method in methods) {
2746+ (method as MethodElementImpl ).enclosingElement = this ;
2747+ }
2748+ _methods = methods;
2749+ }
2750+
27522751 @override
27532752 List <InterfaceType > get mixins => const < InterfaceType > [];
27542753
@@ -2777,18 +2776,6 @@ class EnumElementImpl extends AbstractClassElementImpl {
27772776 builder.writeEnumElement (this );
27782777 }
27792778
2780- /// Create the only method enums have - `toString()` .
2781- void createToStringMethodElement () {
2782- var method = MethodElementImpl ('toString' , - 1 );
2783- method.isSynthetic = true ;
2784- method.enclosingElement = this ;
2785- method.reference = reference? .getChild ('@method' ).getChild ('toString' );
2786- _methods = < MethodElement > [method];
2787- }
2788-
2789- @override
2790- ConstructorElement ? getNamedConstructor (String name) => null ;
2791-
27922779 void setLinkedData (Reference reference, ElementLinkedData linkedData) {
27932780 this .reference = reference;
27942781 reference.element = this ;
@@ -4332,14 +4319,17 @@ class Modifier implements Comparable<Modifier> {
43324319 /// Indicates that the pseudo-modifier 'set' was applied to the element.
43334320 static const Modifier SETTER = Modifier ('SETTER' , 19 );
43344321
4322+ /// See [TypeParameterizedElement.isSimplyBounded] .
4323+ static const Modifier SIMPLY_BOUNDED = Modifier ('SIMPLY_BOUNDED' , 20 );
4324+
43354325 /// Indicates that the modifier 'static' was applied to the element.
4336- static const Modifier STATIC = Modifier ('STATIC' , 20 );
4326+ static const Modifier STATIC = Modifier ('STATIC' , 21 );
43374327
43384328 /// Indicates that the element does not appear in the source code but was
43394329 /// implicitly created. For example, if a class does not define any
43404330 /// constructors, an implicit zero-argument constructor will be created and it
43414331 /// will be marked as being synthetic.
4342- static const Modifier SYNTHETIC = Modifier ('SYNTHETIC' , 21 );
4332+ static const Modifier SYNTHETIC = Modifier ('SYNTHETIC' , 22 );
43434333
43444334 static const List <Modifier > values = [
43454335 ABSTRACT ,
@@ -4362,6 +4352,7 @@ class Modifier implements Comparable<Modifier> {
43624352 MIXIN_APPLICATION ,
43634353 SETTER ,
43644354 STATIC ,
4355+ SIMPLY_BOUNDED ,
43654356 SYNTHETIC
43664357 ];
43674358
@@ -5445,10 +5436,6 @@ class TopLevelVariableElementImpl extends PropertyInducingElementImpl
54455436class TypeAliasElementImpl extends _ExistingElementImpl
54465437 with TypeParameterizedElementMixin
54475438 implements TypeAliasElement {
5448- /// TODO(scheglov) implement as modifier
5449- @override
5450- bool isSimplyBounded = true ;
5451-
54525439 /// Is `true` if the element has direct or indirect reference to itself
54535440 /// from anywhere except a class element or type parameter bounds.
54545441 bool hasSelfReference = false ;
@@ -5518,6 +5505,15 @@ class TypeAliasElementImpl extends _ExistingElementImpl
55185505 return true ;
55195506 }
55205507
5508+ @override
5509+ bool get isSimplyBounded {
5510+ return hasModifier (Modifier .SIMPLY_BOUNDED );
5511+ }
5512+
5513+ set isSimplyBounded (bool isSimplyBounded) {
5514+ setModifier (Modifier .SIMPLY_BOUNDED , isSimplyBounded);
5515+ }
5516+
55215517 @override
55225518 ElementKind get kind {
55235519 if (isNonFunctionTypeAliasesEnabled) {
0 commit comments