Issue 48583. Inherit evaluationResult in DefaultSuperFormalParameterElementImpl.

Bug: https://github.com/dart-lang/sdk/issues/48583
Change-Id: I6217adb5d1e96d2fbb40e4033b9ed62025cd60ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237622
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2022-03-16 18:14:14 +00:00
committed by Commit Bot
parent 8d6fb0f31c
commit eea52d35f8
2 changed files with 42 additions and 0 deletions
@@ -1617,6 +1617,20 @@ class DefaultSuperFormalParameterElementImpl
return null;
}
@override
EvaluationResultImpl? get evaluationResult {
if (constantInitializer != null) {
return super.evaluationResult;
}
var superConstructorParameter = this.superConstructorParameter;
if (superConstructorParameter is ParameterElementImpl) {
return superConstructorParameter.evaluationResult;
}
return null;
}
DartObject? get _superConstructorParameterDefaultValue {
var superDefault = superConstructorParameter?.computeConstantValue();
var superDefaultType = superDefault?.type;
@@ -315,6 +315,34 @@ var v = const A('foo');
]);
}
test_superFormalParameter_explicit() async {
await assertNoErrorsInCode(r'''
class A {
const A({int a = 0});
}
class B extends A {
static const f = B();
const B({super.a = 2});
}
''');
}
test_superFormalParameter_inherited() async {
await assertNoErrorsInCode(r'''
class A {
const A({int a = 0});
}
class B extends A {
static const f = B();
const B({super.a});
}
''');
}
test_unknown_conditionalExpression_unknownCondition() async {
await assertNoErrorsInCode(r'''
const bool kIsWeb = identical(0, 0.0);