mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:37:53 +00:00
Fix a corner case of constant constructor dependency computation.
If a constant constructor does not contain an explicit call to super(), and the base class lacks an explicit constructor, we need to avoid marking the implicit base class constructor as a dependency, since it is non-const. (Note: this shouldn't occur very often in real-world usage since is a compile-time error, but we still need to be able to analyze it without throwing an exception). Fixes the following test when the new task model is switched on: co19/Language/07_Classes/6_Constructors/3_Constant_Constructors_A03_t02 R=brianwilkerson@google.com Review URL: https://codereview.chromium.org//1168563004
This commit is contained in:
parent
b916cbffa4
commit
12696cafe9
|
@ -457,7 +457,7 @@ class ConstantEvaluationEngine {
|
|||
if (superclass != null && !superclass.isObject) {
|
||||
ConstructorElement unnamedConstructor = ConstantEvaluationEngine
|
||||
._getConstructorBase(superclass.element.unnamedConstructor);
|
||||
if (unnamedConstructor != null) {
|
||||
if (unnamedConstructor != null && unnamedConstructor.isConst) {
|
||||
callback(unnamedConstructor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1495,6 +1495,21 @@ const d = a;
|
|||
''');
|
||||
}
|
||||
|
||||
test_const_constructor_calls_implicit_super_constructor_implicitly() {
|
||||
// Note: the situation below is a compile-time error (since the synthetic
|
||||
// constructor for Base is non-const), but we need to handle it without
|
||||
// throwing an exception.
|
||||
EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue(
|
||||
'x', '''
|
||||
class Base {}
|
||||
class Derived extends Base {
|
||||
const Derived();
|
||||
}
|
||||
const x = const Derived();
|
||||
''');
|
||||
expect(evaluationResult, isNotNull);
|
||||
}
|
||||
|
||||
test_dependency() {
|
||||
EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue(
|
||||
'x', '''
|
||||
|
|
Loading…
Reference in a new issue