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

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

Issue 1147853002: Properly handle circular references among constants in the task model. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/lib/src/task/dart.dart » ('j') | pkg/analyzer/test/src/task/dart_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d99506966cc9c041f478f62078785813888c7e68..b0b795867375cbc893541bdd656cb104b5ee6187 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -835,6 +835,37 @@ class ConstantEvaluationEngine {
}
/**
+ * Generate an error indicating that the given [constant] is not a valid
+ * compile-time constant because it references at least one of the constants
+ * in the given [cycle], each of which directly or indirectly references the
+ * constant.
+ */
+ void generateCycleError(Iterable<ConstantEvaluationTarget> cycle,
+ ConstantEvaluationTarget constant) {
+ if (constant is VariableElement) {
+ RecordingErrorListener errorListener = new RecordingErrorListener();
+ ErrorReporter errorReporter =
+ new ErrorReporter(errorListener, constant.source);
+ // TODO(paulberry): It would be really nice if we could extract enough
+ // information from the 'cycle' argument to provide the user with a
+ // description of the cycle.
+ errorReporter.reportErrorForElement(
+ CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT, constant, []);
+ (constant as VariableElementImpl).evaluationResult =
+ new EvaluationResultImpl(null, errorListener.errors);
+ } else if (constant is ConstructorElement) {
+ // We don't report cycle errors on constructor declarations since there
+ // is nowhere to put the error information.
+ } else {
+ // Should not happen. Formal parameter defaults and annotations should
+ // never appear as part of a cycle because they can't be referred to.
+ assert(false);
+ AnalysisEngine.instance.logger.logError(
+ "Constant value computer trying to report a cycle error for a node of type ${constant.runtimeType}");
+ }
+ }
+
+ /**
* If [constructor] redirects to another const constructor, return the
* const constructor it redirects to. Otherwise return `null`.
*/
@@ -1245,7 +1276,7 @@ class ConstantValueComputer {
_computeValueFor(constantsInCycle[0]);
} else {
for (ConstantEvaluationTarget constant in constantsInCycle) {
- _generateCycleError(constantsInCycle, constant);
+ evaluationEngine.generateCycleError(constantsInCycle, constant);
}
}
}
@@ -1266,37 +1297,6 @@ class ConstantValueComputer {
}
evaluationEngine.computeConstantValue(constant);
}
-
- /**
- * Generate an error indicating that the given [constant] is not a valid
- * compile-time constant because it references at least one of the constants
- * in the given [cycle], each of which directly or indirectly references the
- * constant.
- */
- void _generateCycleError(
- List<ConstantEvaluationTarget> cycle, ConstantEvaluationTarget constant) {
- if (constant is VariableElement) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
- ErrorReporter errorReporter =
- new ErrorReporter(errorListener, constant.source);
- // TODO(paulberry): It would be really nice if we could extract enough
- // information from the 'cycle' argument to provide the user with a
- // description of the cycle.
- errorReporter.reportErrorForElement(
- CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT, constant, []);
- (constant as VariableElementImpl).evaluationResult =
- new EvaluationResultImpl(null, errorListener.errors);
- } else if (constant is ConstructorElement) {
- // We don't report cycle errors on constructor declarations since there
- // is nowhere to put the error information.
- } else {
- // Should not happen. Formal parameter defaults and annotations should
- // never appear as part of a cycle because they can't be referred to.
- assert(false);
- AnalysisEngine.instance.logger.logError(
- "Constant value computer trying to report a cycle error for a node of type ${constant.runtimeType}");
- }
- }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | pkg/analyzer/test/src/task/dart_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698