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

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

Issue 1305863011: Improve strong-mode implementation and fix several failing tests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Addressed comments Created 5 years, 3 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 | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/task/strong_mode.dart » ('j') | 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 e81545c1e0cc4a8a9a12a2afc93013cdbb1497b1..3ade0ddff4eb2de4b076e01715509c7ff42185ed 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -72,16 +72,6 @@ final ListResultDescriptor<AnalysisError> BUILD_LIBRARY_ERRORS =
'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS);
/**
- * A list of the [ClassElement]s representing the classes defined in a
- * compilation unit.
- *
- * The result is only available for [LibrarySpecificUnit]s, and only when strong
- * mode is enabled.
- */
-final ListResultDescriptor<ClassElement> CLASSES_IN_UNIT =
- new ListResultDescriptor<ClassElement>('CLASSES_IN_UNIT', null);
-
-/**
* A list of the [ConstantEvaluationTarget]s defined in a unit. This includes
* constants defined at top level, statically inside classes, and local to
* functions, as well as constant constructors, annotations, and default values
@@ -2703,6 +2693,7 @@ class InferStaticVariableTypeTask extends InferStaticVariableTask {
"NodeLocator failed to find a variable's declaration");
}
Expression initializer = declaration.initializer;
+ initializer.accept(new ResolutionEraser());
ResolutionContext resolutionContext =
ResolutionContextBuilder.contextFor(initializer, errorListener);
ResolverVisitor visitor = new ResolverVisitor(
@@ -3141,7 +3132,6 @@ class PartiallyResolveUnitReferencesTask extends SourceBasedAnalysisTask {
'PartiallyResolveUnitReferencesTask',
createTask,
buildInputs, <ResultDescriptor>[
- CLASSES_IN_UNIT,
INFERABLE_STATIC_VARIABLES_IN_UNIT,
PARTIALLY_RESOLVE_REFERENCES_ERRORS,
RESOLVED_UNIT5
@@ -3169,29 +3159,14 @@ class PartiallyResolveUnitReferencesTask extends SourceBasedAnalysisTask {
//
InheritanceManager inheritanceManager =
new InheritanceManager(libraryElement);
- // TODO(brianwilkerson) Improve performance by not resolving anything inside
- // function bodies. Function bodies will be resolved later so this is wasted
- // effort.
- AstVisitor visitor = new ResolverVisitor(
+ PartialResolverVisitor visitor = new PartialResolverVisitor(
libraryElement, unitElement.source, typeProvider, errorListener,
inheritanceManager: inheritanceManager);
unit.accept(visitor);
//
- // Prepare targets for inference.
- //
- List<VariableElement> staticVariables = <VariableElement>[];
- List<ClassElement> classes = <ClassElement>[];
- if (context.analysisOptions.strongMode) {
- InferrenceFinder inferrenceFinder = new InferrenceFinder();
- unit.accept(inferrenceFinder);
- staticVariables = inferrenceFinder.staticVariables;
- classes = inferrenceFinder.classes;
- }
- //
// Record outputs.
//
- outputs[CLASSES_IN_UNIT] = classes;
- outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = staticVariables;
+ outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.staticVariables;
outputs[PARTIALLY_RESOLVE_REFERENCES_ERRORS] =
removeDuplicateErrors(errorListener.errors);
outputs[RESOLVED_UNIT5] = unit;
@@ -3438,8 +3413,18 @@ class ResolveFunctionBodiesInUnitTask extends SourceBasedAnalysisTask {
visitor.prepareToResolveMembersInClass(
resolutionContext.enclosingClassDeclaration);
}
- visitor.initForIncrementalResolution();
+ Declaration declaration = functionBody.getAncestor((AstNode node) =>
+ node is ConstructorDeclaration ||
+ node is FunctionDeclaration ||
+ node is MethodDeclaration);
+ visitor.initForIncrementalResolution(declaration);
functionBody.accept(visitor);
+ if (declaration is FunctionDeclaration) {
+ // This is in the wrong place. The propagated return type is stored
+ // locally in the resolver, not in the declaration (or element). Hence,
+ // this needs to happen later.
+ declaration.accept(visitor.typeAnalyzer);
+ }
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/task/strong_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698