| Index: pkg/analyzer/lib/src/task/dart.dart
|
| diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
|
| index 338e8893ac31a73fe627a71b9c877d78e75c8cc7..567f63490b786bfde5c07fa7d173cf562d6511dc 100644
|
| --- a/pkg/analyzer/lib/src/task/dart.dart
|
| +++ b/pkg/analyzer/lib/src/task/dart.dart
|
| @@ -19,6 +19,7 @@ import 'package:analyzer/src/generated/resolver.dart';
|
| import 'package:analyzer/src/generated/scanner.dart';
|
| import 'package:analyzer/src/generated/sdk.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| +import 'package:analyzer/src/task/driver.dart';
|
| import 'package:analyzer/src/task/general.dart';
|
| import 'package:analyzer/src/task/model.dart';
|
| import 'package:analyzer/task/dart.dart';
|
| @@ -1785,6 +1786,9 @@ class ComputeConstantValueTask extends ConstantEvaluationAnalysisTask {
|
| TaskDescriptor get descriptor => DESCRIPTOR;
|
|
|
| @override
|
| + bool get handlesDependencyCycles => true;
|
| +
|
| + @override
|
| void internalPerform() {
|
| //
|
| // Prepare inputs.
|
| @@ -1796,10 +1800,24 @@ class ComputeConstantValueTask extends ConstantEvaluationAnalysisTask {
|
| AnalysisContext context = constant.context;
|
| TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
|
| //
|
| - // Compute the value of the constant.
|
| + // Compute the value of the constant, or report an error if there was a
|
| + // cycle.
|
| //
|
| - new ConstantEvaluationEngine(typeProvider, context.declaredVariables)
|
| - .computeConstantValue(constant);
|
| + ConstantEvaluationEngine constantEvaluationEngine =
|
| + new ConstantEvaluationEngine(typeProvider, context.declaredVariables);
|
| + if (dependencyCycle == null) {
|
| + constantEvaluationEngine.computeConstantValue(constant);
|
| + } else {
|
| + List<ConstantEvaluationTarget> constantsInCycle =
|
| + <ConstantEvaluationTarget>[];
|
| + for (WorkItem workItem in dependencyCycle) {
|
| + if (workItem.descriptor == DESCRIPTOR) {
|
| + constantsInCycle.add(workItem.target);
|
| + }
|
| + }
|
| + assert(constantsInCycle.isNotEmpty);
|
| + constantEvaluationEngine.generateCycleError(constantsInCycle, constant);
|
| + }
|
| //
|
| // Record outputs.
|
| //
|
| @@ -3244,11 +3262,6 @@ class _ExportSourceClosureTaskInput implements TaskInput<List<Source>> {
|
| }
|
|
|
| /**
|
| - * The kind of the source closure to build.
|
| - */
|
| -enum _SourceClosureKind { IMPORT, EXPORT, IMPORT_EXPORT }
|
| -
|
| -/**
|
| * A [TaskInput] whose value is a list of library sources imported or exported,
|
| * directly or indirectly by the target [Source].
|
| */
|
| @@ -3278,6 +3291,11 @@ class _ImportSourceClosureTaskInput implements TaskInput<List<Source>> {
|
| }
|
|
|
| /**
|
| + * The kind of the source closure to build.
|
| + */
|
| +enum _SourceClosureKind { IMPORT, EXPORT, IMPORT_EXPORT }
|
| +
|
| +/**
|
| * A [TaskInputBuilder] to build values for [_ImportSourceClosureTaskInput].
|
| */
|
| class _SourceClosureTaskInputBuilder implements TaskInputBuilder<List<Source>> {
|
| @@ -3320,6 +3338,12 @@ class _SourceClosureTaskInputBuilder implements TaskInputBuilder<List<Source>> {
|
| }
|
|
|
| @override
|
| + void currentValueNotAvailable() {
|
| + // Nothing needs to be done. moveNext() will simply go on to the next new
|
| + // source.
|
| + }
|
| +
|
| + @override
|
| bool moveNext() {
|
| if (_newSources.isEmpty) {
|
| return false;
|
|
|