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

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

Issue 3000743002: Check for null constructor field initializer expression. (Closed)
Patch Set: Check for null in ConstantEvaluationEngine instead. Created 3 years, 4 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 | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/constant/evaluation.dart
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 9dc5c7e510c182f0aeba1ce28f2417a1d2bb7e39..fc3ee08a412129963d06152b5ec9e98c641ff8a3 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -709,7 +709,7 @@ class ConstantEvaluationEngine {
if (initializer is ConstructorFieldInitializer) {
Expression initializerExpression = initializer.expression;
DartObjectImpl evaluationResult =
- initializerExpression.accept(initializerVisitor);
+ initializerExpression?.accept(initializerVisitor);
if (evaluationResult != null) {
String fieldName = initializer.fieldName.name;
if (fieldMap.containsKey(fieldName)) {
@@ -728,6 +728,9 @@ class ConstantEvaluationEngine {
[evaluationResult.type, fieldName, field.type]);
}
}
+ } else {
+ errorReporter.reportErrorForNode(
+ CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, node);
}
} else if (initializer is SuperConstructorInvocation) {
SimpleIdentifier name = initializer.constructorName;
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698