Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart |
| diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart |
| index 096c14b0abb4c95b4f5ca10dea94c34e46698db6..9415881cfd25ad1d9dc02e69277d50908e51bd8a 100644 |
| --- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart |
| +++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart |
| @@ -543,8 +543,10 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> { |
| } |
| } |
| } |
| - _recordStaticType(node, _typeProvider.mapType |
| - .substitute4(<DartType>[staticKeyType, staticValueType])); |
| + _recordStaticType( |
| + node, |
| + _typeProvider.mapType |
| + .substitute4(<DartType>[staticKeyType, staticValueType])); |
| return null; |
| } |
| @@ -1179,9 +1181,25 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> { |
| return null; |
| } |
| + void _inferLocalVariableType( |
| + VariableDeclaration node, Expression initializer) { |
| + if (initializer != null && |
| + (node.parent as VariableDeclarationList).type == null && |
| + (node.element is LocalVariableElementImpl) && |
| + (initializer.staticType != null) && |
| + (initializer.staticType != _typeProvider.bottomType)) { |
|
Paul Berry
2015/08/27 01:28:11
Nit: use initializer.staticType.isBottom.
Leaf
2015/08/27 18:15:26
Done.
|
| + LocalVariableElementImpl element = node.element; |
| + element.type = initializer.staticType; |
| + node.name.staticType = initializer.staticType; |
| + } |
| + } |
| + |
| @override |
| Object visitVariableDeclaration(VariableDeclaration node) { |
| Expression initializer = node.initializer; |
| + if (_resolver.definingLibrary.context.analysisOptions.strongMode) { |
| + _inferLocalVariableType(node, initializer); |
| + } |
| if (initializer != null) { |
| DartType rightType = initializer.bestType; |
| SimpleIdentifier name = node.name; |