@@ -481,24 +481,17 @@ class ClassElementImpl extends InterfaceElementImpl implements ClassElement {
481481 var formalParameterElements = < FormalParameterElementImpl > [];
482482 var superInvocationArguments = < ExpressionImpl > [];
483483 for (var superFormalParameter in superConstructor.formalParameters) {
484- FormalParameterFragmentImpl formalParameterFragment;
485- if (superFormalParameter.firstFragment
486- case ConstVariableFragment constVariable) {
487- // TODO(scheglov): Maybe stop making this distinction
488- formalParameterFragment = DefaultParameterFragmentImpl (
484+ var formalParameterFragment = FormalParameterFragmentImpl (
489485 nameOffset: - 1 ,
490486 name2: superFormalParameter.name3,
491487 nameOffset2: null ,
492488 parameterKind: superFormalParameter.parameterKind,
493- )..constantInitializer = constVariable.constantInitializer;
494- } else {
495- formalParameterFragment = FormalParameterFragmentImpl (
496- nameOffset: - 1 ,
497- name2: superFormalParameter.name3,
498- nameOffset2: null ,
499- parameterKind: superFormalParameter.parameterKind,
500- );
501- }
489+ )
490+ ..constantInitializer =
491+ superFormalParameter
492+ .baseElement
493+ .firstFragment
494+ .constantInitializer;
502495
503496 formalParameterFragment.isConst = superFormalParameter.isConst;
504497 formalParameterFragment.isFinal = superFormalParameter.isFinal;
@@ -1178,10 +1171,7 @@ mixin ConstVariableFragment implements FragmentImpl, ConstantEvaluationTarget {
11781171 var library = this .library;
11791172 // TODO(scheglov): https://github.com/dart-lang/sdk/issues/47915
11801173 if (library == null ) {
1181- throw StateError (
1182- '[library: null][this: ($runtimeType ) $this ]'
1183- '[enclosingElement: $enclosingElement3 ]' ,
1184- );
1174+ return null ;
11851175 }
11861176 computeConstants (
11871177 declaredVariables: context.declaredVariables,
@@ -1217,24 +1207,6 @@ class DefaultFieldFormalParameterElementImpl
12171207 }
12181208}
12191209
1220- /// A [FormalParameterFragmentImpl] for parameters that have an initializer.
1221- class DefaultParameterFragmentImpl extends FormalParameterFragmentImpl
1222- with ConstVariableFragment {
1223- /// Initialize a newly created parameter element to have the given [name] and
1224- /// [nameOffset] .
1225- DefaultParameterFragmentImpl ({
1226- required super .nameOffset,
1227- required super .name2,
1228- required super .nameOffset2,
1229- required super .parameterKind,
1230- });
1231-
1232- @override
1233- String ? get defaultValueCode {
1234- return constantInitializer? .toSource ();
1235- }
1236- }
1237-
12381210class DefaultSuperFormalParameterElementImpl
12391211 extends SuperFormalParameterFragmentImpl
12401212 with ConstVariableFragment {
@@ -3424,7 +3396,9 @@ class FormalParameterFragmentImpl extends VariableFragmentImpl
34243396 FormalParameterFragmentImpl get declaration => this ;
34253397
34263398 @override
3427- String ? get defaultValueCode => null ;
3399+ String ? get defaultValueCode {
3400+ return constantInitializer? .toSource ();
3401+ }
34283402
34293403 @override
34303404 FormalParameterElementImpl get element {
@@ -10387,6 +10361,7 @@ abstract class VariableElementOrMember
1038710361}
1038810362
1038910363abstract class VariableFragmentImpl extends FragmentImpl
10364+ with ConstVariableFragment
1039010365 implements
1039110366 VariableElementOrMember ,
1039210367 AnnotatableFragmentImpl ,
@@ -10398,15 +10373,6 @@ abstract class VariableFragmentImpl extends FragmentImpl
1039810373 /// [offset] .
1039910374 VariableFragmentImpl ({required super .nameOffset});
1040010375
10401- /// If this element represents a constant variable, and it has an initializer,
10402- /// a copy of the initializer for the constant. Otherwise `null` .
10403- ///
10404- /// Note that in correct Dart code, all constant variables must have
10405- /// initializers. However, analyzer also needs to handle incorrect Dart code,
10406- /// in which case there might be some constant variables that lack
10407- /// initializers.
10408- ExpressionImpl ? get constantInitializer => null ;
10409-
1041010376 @override
1041110377 VariableFragmentImpl get declaration => this ;
1041210378
@@ -10416,18 +10382,6 @@ abstract class VariableFragmentImpl extends FragmentImpl
1041610382 @override
1041710383 VariableElementImpl get element;
1041810384
10419- /// Return the result of evaluating this variable's initializer as a
10420- /// compile-time constant expression, or `null` if this variable is not a
10421- /// 'const' variable, if it does not have an initializer, or if the
10422- /// compilation unit containing the variable has not been resolved.
10423- Constant ? get evaluationResult => null ;
10424-
10425- /// Set the result of evaluating this variable's initializer as a compile-time
10426- /// constant expression to the given [result] .
10427- set evaluationResult (Constant ? result) {
10428- throw StateError ("Invalid attempt to set a compile-time constant result" );
10429- }
10430-
1043110385 @override
1043210386 bool get hasImplicitType {
1043310387 return hasModifier (Modifier .IMPLICIT_TYPE );
@@ -10458,9 +10412,6 @@ abstract class VariableFragmentImpl extends FragmentImpl
1045810412 setModifier (Modifier .CONST , isConst);
1045910413 }
1046010414
10461- @override
10462- bool get isConstantEvaluated => true ;
10463-
1046410415 /// Set whether this variable is external.
1046510416 set isExternal (bool isExternal) {
1046610417 setModifier (Modifier .EXTERNAL , isExternal);
@@ -10502,9 +10453,6 @@ abstract class VariableFragmentImpl extends FragmentImpl
1050210453 void appendTo (ElementDisplayStringBuilder builder) {
1050310454 builder.writeVariableElement (this );
1050410455 }
10505-
10506- @override
10507- DartObject ? computeConstantValue () => null ;
1050810456}
1050910457
1051010458mixin WrappedElementMixin implements ElementImpl {
0 commit comments