Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart

Issue 2104843002: Handle fields with initializers in constant constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix invariants. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index f81a6caaf604240ebd048d5a954e54b6e4fce99a..f8ae6eae90e378cef8487195db16b252e87127e3 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -856,20 +856,27 @@ class TypeGraphInferrerEngine
if (constant != null) {
ConstantValue value =
compiler.backend.constants.getConstantValue(constant);
- assert(invariant(fieldElement, value != null,
- message: "Constant expression without value: "
- "${constant.toStructuredText()}."));
- if (value.isFunction) {
- FunctionConstantValue functionConstant = value;
- type = types.allocateClosure(node, functionConstant.element);
+ if (value != null) {
+ if (value.isFunction) {
+ FunctionConstantValue functionConstant = value;
+ type = types.allocateClosure(node, functionConstant.element);
+ } else {
+ // Although we might find a better type, we have to keep
+ // the old type around to ensure that we get a complete view
+ // of the type graph and do not drop any flow edges.
+ TypeMask refinedType = computeTypeMask(compiler, value);
+ assert(TypeMask.assertIsNormalized(refinedType, classWorld));
+ type = new NarrowTypeInformation(type, refinedType);
+ types.allocatedTypes.add(type);
+ }
} else {
- // Although we might find a better type, we have to keep
- // the old type around to ensure that we get a complete view
- // of the type graph and do not drop any flow edges.
- TypeMask refinedType = computeTypeMask(compiler, value);
- assert(TypeMask.assertIsNormalized(refinedType, classWorld));
- type = new NarrowTypeInformation(type, refinedType);
- types.allocatedTypes.add(type);
+ assert(invariant(
+ fieldElement,
+ fieldElement.isInstanceMember ||
+ constant.isImplicit ||
+ constant.isPotential,
+ message: "Constant expression without value: "
+ "${constant.toStructuredText()}."));
}
}
}
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698