OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.task.dart; | 5 library analyzer.src.task.dart; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
(...skipping 3737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3748 // re-resolve the right hand side and do inference. | 3748 // re-resolve the right hand side and do inference. |
3749 List<AnalysisError> errors = AnalysisError.NO_ERRORS; | 3749 List<AnalysisError> errors = AnalysisError.NO_ERRORS; |
3750 if (dependencyCycle == null && variable.hasImplicitType) { | 3750 if (dependencyCycle == null && variable.hasImplicitType) { |
3751 VariableDeclaration declaration = getDeclaration(unit); | 3751 VariableDeclaration declaration = getDeclaration(unit); |
3752 // | 3752 // |
3753 // Re-resolve the variable's initializer so that the inferred types | 3753 // Re-resolve the variable's initializer so that the inferred types |
3754 // of other variables will be propagated. | 3754 // of other variables will be propagated. |
3755 // | 3755 // |
3756 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3756 RecordingErrorListener errorListener = new RecordingErrorListener(); |
3757 Expression initializer = declaration.initializer; | 3757 Expression initializer = declaration.initializer; |
3758 ResolutionContext resolutionContext = | |
3759 ResolutionContextBuilder.contextFor(initializer); | |
3760 ResolverVisitor visitor = new ResolverVisitor( | |
3761 variable.library, variable.source, typeProvider, errorListener, | |
3762 nameScope: resolutionContext.scope); | |
3763 if (resolutionContext.enclosingClassDeclaration != null) { | |
3764 visitor.prepareToResolveMembersInClass( | |
3765 resolutionContext.enclosingClassDeclaration); | |
3766 } | |
3767 visitor.initForIncrementalResolution(); | |
3768 initializer.accept(visitor); | |
3769 | 3758 |
3770 DartType newType; | 3759 DartType newType; |
3771 if (!isValidForTypeInference(initializer)) { | 3760 if (!isValidForTypeInference(initializer)) { |
3772 newType = typeProvider.dynamicType; | 3761 newType = typeProvider.dynamicType; |
3773 } else { | 3762 } else { |
| 3763 ResolutionContext resolutionContext = |
| 3764 ResolutionContextBuilder.contextFor(initializer); |
| 3765 ResolverVisitor visitor = new ResolverVisitor( |
| 3766 variable.library, variable.source, typeProvider, errorListener, |
| 3767 nameScope: resolutionContext.scope, isTopLevelInference: true); |
| 3768 if (resolutionContext.enclosingClassDeclaration != null) { |
| 3769 visitor.prepareToResolveMembersInClass( |
| 3770 resolutionContext.enclosingClassDeclaration); |
| 3771 } |
| 3772 visitor.initForIncrementalResolution(); |
| 3773 initializer.accept(visitor); |
3774 newType = initializer.staticType; | 3774 newType = initializer.staticType; |
3775 if (newType == null || newType.isBottom || newType.isDartCoreNull) { | 3775 if (newType == null || newType.isBottom || newType.isDartCoreNull) { |
3776 newType = typeProvider.dynamicType; | 3776 newType = typeProvider.dynamicType; |
3777 } | 3777 } |
3778 } | 3778 } |
3779 | 3779 |
3780 // | 3780 // |
3781 // Record the type of the variable. | 3781 // Record the type of the variable. |
3782 // | 3782 // |
3783 setFieldType(variable, newType); | 3783 setFieldType(variable, newType); |
(...skipping 2803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6587 | 6587 |
6588 @override | 6588 @override |
6589 bool moveNext() { | 6589 bool moveNext() { |
6590 if (_newSources.isEmpty) { | 6590 if (_newSources.isEmpty) { |
6591 return false; | 6591 return false; |
6592 } | 6592 } |
6593 currentTarget = _newSources.removeLast(); | 6593 currentTarget = _newSources.removeLast(); |
6594 return true; | 6594 return true; |
6595 } | 6595 } |
6596 } | 6596 } |
OLD | NEW |