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

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

Issue 2983293002: Remove toplevel inference restriction hints, and restore as much (Closed)
Patch Set: Keep error filter Created 3 years, 5 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/summary/link.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.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 f32871be67d8b8fe8cadbcc3f636a7293b193f93..b92f4300484ed0b18d2b00f8827b0c04e0dd218f 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -3155,36 +3155,13 @@ class InferInstanceMembersInUnitTask extends SourceBasedAnalysisTask {
TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
//
- // Prepare fields for which inference should be disabled.
- //
- Set<FieldElement> fieldsWithDisabledInference = new Set<FieldElement>();
- for (CompilationUnitMember classDeclaration in unit.declarations) {
- if (classDeclaration is ClassDeclaration) {
- for (ClassMember fieldDeclaration in classDeclaration.members) {
- if (fieldDeclaration is FieldDeclaration) {
- if (!fieldDeclaration.isStatic) {
- for (VariableDeclaration field
- in fieldDeclaration.fields.variables) {
- Expression initializer = field.initializer;
- if (initializer != null &&
- !isValidForTypeInference(initializer)) {
- fieldsWithDisabledInference.add(field.element);
- }
- }
- }
- }
- }
- }
- }
-
- //
// Infer instance members.
//
if (context.analysisOptions.strongMode) {
var inheritanceManager = new InheritanceManager(
resolutionMap.elementDeclaredByCompilationUnit(unit).library);
InstanceMemberInferrer inferrer = new InstanceMemberInferrer(
- typeProvider, (_) => inheritanceManager, fieldsWithDisabledInference,
+ typeProvider, (_) => inheritanceManager,
typeSystem: context.typeSystem);
inferrer.inferCompilationUnit(unit.element);
}
@@ -3446,25 +3423,20 @@ class InferStaticVariableTypeTask extends InferStaticVariableTask {
RecordingErrorListener errorListener = new RecordingErrorListener();
Expression initializer = declaration.initializer;
- DartType newType;
- if (!isValidForTypeInference(initializer)) {
+ ResolutionContext resolutionContext =
+ ResolutionContextBuilder.contextFor(initializer);
+ ResolverVisitor visitor = new ResolverVisitor(
+ variable.library, variable.source, typeProvider, errorListener,
+ nameScope: resolutionContext.scope);
+ if (resolutionContext.enclosingClassDeclaration != null) {
+ visitor.prepareToResolveMembersInClass(
+ resolutionContext.enclosingClassDeclaration);
+ }
+ visitor.initForIncrementalResolution();
+ initializer.accept(visitor);
+ DartType newType = initializer.staticType;
+ if (newType == null || newType.isBottom || newType.isDartCoreNull) {
newType = typeProvider.dynamicType;
- } else {
- ResolutionContext resolutionContext =
- ResolutionContextBuilder.contextFor(initializer);
- ResolverVisitor visitor = new ResolverVisitor(
- variable.library, variable.source, typeProvider, errorListener,
- nameScope: resolutionContext.scope);
- if (resolutionContext.enclosingClassDeclaration != null) {
- visitor.prepareToResolveMembersInClass(
- resolutionContext.enclosingClassDeclaration);
- }
- visitor.initForIncrementalResolution();
- initializer.accept(visitor);
- newType = initializer.staticType;
- if (newType == null || newType.isBottom || newType.isDartCoreNull) {
- newType = typeProvider.dynamicType;
- }
}
//
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698