@@ -2973,6 +2973,11 @@ class FormalParameterElementImpl extends PromotableElementImpl
29732973 @override
29742974 late TypeImpl type;
29752975
2976+ /// Whether this formal parameter inherits from a covariant formal parameter.
2977+ /// This happens when it overrides a method in a supertype that has a
2978+ /// corresponding covariant formal parameter.
2979+ bool inheritsCovariant = false ;
2980+
29762981 FormalParameterElementImpl (this .wrappedElement) {
29772982 FormalParameterFragmentImpl ? fragment = wrappedElement;
29782983 while (fragment != null ) {
@@ -3033,8 +3038,12 @@ class FormalParameterElementImpl extends PromotableElementImpl
30333038 bool get isConst => wrappedElement.isConst;
30343039
30353040 @override
3036- // TODO(augmentations): Implement the merge of formal parameters.
3037- bool get isCovariant => wrappedElement.isCovariant;
3041+ bool get isCovariant {
3042+ if (firstFragment.isExplicitlyCovariant || inheritsCovariant) {
3043+ return true ;
3044+ }
3045+ return false ;
3046+ }
30383047
30393048 @override
30403049 // TODO(augmentations): Implement the merge of formal parameters.
@@ -3210,11 +3219,6 @@ class FormalParameterFragmentImpl extends VariableFragmentImpl
32103219 /// Prefer using `isXyz` instead, e.g. [isRequiredNamed] .
32113220 final ParameterKind parameterKind;
32123221
3213- /// True if this parameter inherits from a covariant parameter. This happens
3214- /// when it overrides a method in a supertype that has a corresponding
3215- /// covariant parameter.
3216- bool inheritsCovariant = false ;
3217-
32183222 /// The element corresponding to this fragment.
32193223 FormalParameterElementImpl ? _element;
32203224
@@ -3277,15 +3281,6 @@ class FormalParameterFragmentImpl extends VariableFragmentImpl
32773281 @override
32783282 Fragment ? get enclosingFragment => enclosingElement as Fragment ? ;
32793283
3280- /// Whether the parameter is covariant, meaning it is allowed to have a
3281- /// narrower type in an override.
3282- bool get isCovariant {
3283- if (isExplicitlyCovariant || inheritsCovariant) {
3284- return true ;
3285- }
3286- return false ;
3287- }
3288-
32893284 /// Return true if this parameter is explicitly marked as being covariant.
32903285 bool get isExplicitlyCovariant {
32913286 return hasModifier (Modifier .COVARIANT );
@@ -4829,6 +4824,10 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
48294824
48304825 List <ConstructorElementImpl > _constructors = _Sentinel .constructorElement;
48314826
4827+ /// A flag indicating whether the types associated with the instance members
4828+ /// of this class have been inferred.
4829+ bool hasBeenInferred = false ;
4830+
48324831 @override
48334832 List <InterfaceTypeImpl > get allSupertypes {
48344833 return _allSupertypes ?? = library.session.classHierarchy
@@ -5185,10 +5184,6 @@ abstract class InterfaceFragmentImpl extends InstanceFragmentImpl
51855184
51865185 InterfaceTypeImpl ? _supertype;
51875186
5188- /// A flag indicating whether the types associated with the instance members
5189- /// of this class have been inferred.
5190- bool hasBeenInferred = false ;
5191-
51925187 List <ConstructorFragmentImpl > _constructors = _Sentinel .constructorFragment;
51935188
51945189 /// Initialize a newly created class element to have the given [name] at the
@@ -7553,6 +7548,15 @@ class MethodElementImpl extends ExecutableElementImpl
75537548 @override
75547549 final MethodFragmentImpl firstFragment;
75557550
7551+ /// Is `true` if this method is `operator==` , and there is no explicit
7552+ /// type specified for its formal parameter, in this method or in any
7553+ /// overridden methods other than the one declared in `Object` .
7554+ bool isOperatorEqualWithParameterTypeFromObject = false ;
7555+
7556+ /// The error reported during type inference for this variable, or `null` if
7557+ /// this variable is not a subject of type inference, or there was no error.
7558+ TopLevelInferenceError ? typeInferenceError;
7559+
75567560 MethodElementImpl ({
75577561 required this .name,
75587562 required this .reference,
@@ -7645,15 +7649,6 @@ class MethodFragmentImpl extends ExecutableFragmentImpl
76457649 @override
76467650 MethodFragmentImpl ? nextFragment;
76477651
7648- /// Is `true` if this method is `operator==` , and there is no explicit
7649- /// type specified for its formal parameter, in this method or in any
7650- /// overridden methods other than the one declared in `Object` .
7651- bool isOperatorEqualWithParameterTypeFromObject = false ;
7652-
7653- /// The error reported during type inference for this variable, or `null` if
7654- /// this variable is not a subject of type inference, or there was no error.
7655- TopLevelInferenceError ? typeInferenceError;
7656-
76577652 /// Initialize a newly created method element to have the given [name] at the
76587653 /// given [offset] .
76597654 MethodFragmentImpl ({required this .name, required super .firstTokenOffset});
0 commit comments