Index: tests/compiler/dart2js/kernel/impact_test.dart |
diff --git a/tests/compiler/dart2js/kernel/impact_test.dart b/tests/compiler/dart2js/kernel/impact_test.dart |
index 60a95b9147afe7caf127a759ef6d34a42bd45e77..4d176adfd4f9388737e5009b1a981519bb533f89 100644 |
--- a/tests/compiler/dart2js/kernel/impact_test.dart |
+++ b/tests/compiler/dart2js/kernel/impact_test.dart |
@@ -4,16 +4,17 @@ |
library dart2js.kernel.impact_test; |
-import 'dart:async'; |
import 'package:async_helper/async_helper.dart'; |
import 'package:compiler/src/commandline_options.dart'; |
import 'package:compiler/src/common.dart'; |
import 'package:compiler/src/common/names.dart'; |
import 'package:compiler/src/common/resolution.dart'; |
import 'package:compiler/src/compiler.dart'; |
+import 'package:compiler/src/constants/expressions.dart'; |
import 'package:compiler/src/dart_types.dart'; |
import 'package:compiler/src/elements/elements.dart'; |
import 'package:compiler/src/resolution/registry.dart'; |
+import 'package:compiler/src/resolution/tree_elements.dart'; |
import 'package:compiler/src/ssa/kernel_impact.dart'; |
import 'package:compiler/src/serialization/equivalence.dart'; |
import 'package:compiler/src/universe/call_structure.dart'; |
@@ -151,6 +152,7 @@ main() { |
testDefaultValuesNamed(); |
testFieldInitializer1(); |
testFieldInitializer2(); |
+ testFieldInitializer3(); |
testInstanceFieldWithInitializer(); |
testInstanceFieldTyped(); |
testThisInitializer(); |
@@ -478,6 +480,15 @@ class ClassFieldInitializer2 { |
ClassFieldInitializer2(value) : field = value; |
} |
testFieldInitializer2() => new ClassFieldInitializer2(42); |
+class ClassFieldInitializer3 { |
+ var field; |
+ ClassFieldInitializer3.a(); |
+ ClassFieldInitializer3.b(value) : field = value; |
+} |
+testFieldInitializer3() { |
+ new ClassFieldInitializer3.a(); |
+ new ClassFieldInitializer3.b(42); |
+} |
class ClassInstanceFieldWithInitializer { |
var field = false; |
} |
@@ -671,6 +682,38 @@ ResolutionImpact laxImpact( |
impact.mapLiterals.forEach(builder.registerMapLiteral); |
for (Feature feature in impact.features) { |
switch (feature) { |
+ case Feature.FIELD_WITHOUT_INITIALIZER: |
+ if (element.isInstanceMember) { |
+ bool missing = false; |
+ OUTER: |
+ for (ConstructorElement constructor |
+ in element.enclosingClass.constructors) { |
+ if (constructor.isGenerativeConstructor && |
+ !constructor.isRedirectingGenerative) { |
+ for (ParameterElement parameter in constructor.parameters) { |
+ if (parameter is InitializingFormalElement && |
+ parameter.fieldElement == element) { |
+ continue OUTER; |
+ } |
+ } |
+ if (constructor.resolvedAst.kind == ResolvedAstKind.PARSED) { |
+ var function = constructor.resolvedAst.node; |
+ if (function.initializers != null) { |
+ TreeElements elements = constructor.resolvedAst.elements; |
+ for (var initializer in function.initializers) { |
+ if (elements[initializer] == element) { |
+ continue OUTER; |
+ } |
+ } |
+ } |
+ } |
+ missing = true; |
+ } |
+ } |
+ if (!missing) continue; |
+ } |
+ builder.registerConstantLiteral(new NullConstantExpression()); |
+ break; |
case Feature.STRING_INTERPOLATION: |
case Feature.STRING_JUXTAPOSITION: |
// These are both converted into a string concatenation in kernel so |