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

Unified Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 652833002: Fix constant evaluation in the presence of nonexistent fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index d47db7daaf6125ff5af6684f9e86da752f15333a..b04f8198bdc87ec09780b1bb930e305342269dc2 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -776,12 +776,14 @@ class ConstantValueComputer {
String fieldName = constructorFieldInitializer.fieldName.name;
fieldMap[fieldName] = evaluationResult;
PropertyAccessorElement getter = definingClass.getGetter(fieldName);
- PropertyInducingElement field = getter.variable;
- if (!evaluationResult.isNull &&
- !evaluationResult.type.isSubtypeOf(field.type)) {
- errorReporter.reportErrorForNode(
- CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
- node, [evaluationResult.type, fieldName, field.type]);
+ if (getter != null) {
+ PropertyInducingElement field = getter.variable;
+ if (!evaluationResult.isNull &&
+ !evaluationResult.type.isSubtypeOf(field.type)) {
+ errorReporter.reportErrorForNode(
+ CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
+ node, [evaluationResult.type, fieldName, field.type]);
+ }
}
}
} else if (initializer is SuperConstructorInvocation) {
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | tests/language/compile_time_constant13_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698