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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1403293006: Fix the dependencies for constant evaluation (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25352ead1b006dcccc74689939fb0b1c79aba731..33a4c6f5e13ea4647f2fa13b25f95dd556e39e19 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -1556,11 +1556,6 @@ class BuildTypeProviderTask extends SourceBasedAnalysisTask {
*/
class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask {
/**
- * The name of the [RESOLVED_UNIT9] input.
- */
- static const String UNIT_INPUT = 'UNIT_INPUT';
-
- /**
* The name of the [TYPE_PROVIDER] input.
*/
static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
@@ -1583,10 +1578,6 @@ class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask {
//
// Prepare inputs.
//
- // Note: UNIT_INPUT is not needed. It is merely a bookkeeping dependency
- // to ensure that resolution has occurred before we attempt to determine
- // constant dependencies.
- //
ConstantEvaluationTarget constant = target;
TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
//
@@ -1608,18 +1599,31 @@ class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask {
* given [target].
*/
static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ //
+ // We need to force the computation of the RESOLVED_UNIT9 for each unit
+ // reachable from the target's library so that all of the AST's for the
+ // contructor initializers that we might encounter have been copied into
+ // the element model.
+ //
+ // TODO(brianwilkerson) This could be improved by computing a more accurate
+ // list of the sources containing constructors that are actually referenced.
+ //
if (target is Element) {
CompilationUnitElementImpl unit = target
.getAncestor((Element element) => element is CompilationUnitElement);
+ Source librarySource = unit.librarySource;
return <String, TaskInput>{
- UNIT_INPUT: RESOLVED_UNIT9
- .of(new LibrarySpecificUnit(unit.librarySource, target.source)),
+ 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE.of(librarySource).toList(
+ (Source library) => UNITS.of(library).toList((Source source) =>
+ RESOLVED_UNIT9.of(new LibrarySpecificUnit(library, source)))),
TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
};
} else if (target is ConstantEvaluationTarget_Annotation) {
+ Source librarySource = target.librarySource;
return <String, TaskInput>{
- UNIT_INPUT: RESOLVED_UNIT9
- .of(new LibrarySpecificUnit(target.librarySource, target.source)),
+ 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE.of(librarySource).toList(
+ (Source library) => UNITS.of(library).toList((Source source) =>
+ RESOLVED_UNIT9.of(new LibrarySpecificUnit(library, source)))),
TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
};
}
@@ -3926,6 +3930,10 @@ class ResolveUnitTask extends SourceBasedAnalysisTask {
//
// Record outputs.
//
+ // TODO(brianwilkerson) This task modifies the element model (by copying the
+ // AST's for constructor initializers into it) but does not produce an
+ // updated version of the element model.
+ //
outputs[RESOLVE_UNIT_ERRORS] = errorListener.errors;
outputs[RESOLVED_UNIT9] = unit;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698