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()}.")); |
} |
} |
} |