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 import 'package:analyzer/analyzer.dart' as analyzer; | 5 import 'package:analyzer/analyzer.dart' as analyzer; |
6 import 'package:analyzer/dart/ast/ast.dart'; | 6 import 'package:analyzer/dart/ast/ast.dart'; |
7 import 'package:analyzer/dart/element/type.dart' show DartType; | 7 import 'package:analyzer/dart/element/type.dart' show DartType; |
8 import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl; | 8 import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl; |
9 import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer; | 9 import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer; |
10 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; | 10 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; |
(...skipping 27 matching lines...) Expand all Loading... |
38 @override | 38 @override |
39 visitExpression(Expression node) { | 39 visitExpression(Expression node) { |
40 var coercion = CoercionInfo.get(node); | 40 var coercion = CoercionInfo.get(node); |
41 if (coercion is DownCast) { | 41 if (coercion is DownCast) { |
42 return _visitDownCast(coercion, node); | 42 return _visitDownCast(coercion, node); |
43 } | 43 } |
44 return super.visitExpression(node); | 44 return super.visitExpression(node); |
45 } | 45 } |
46 | 46 |
47 @override | 47 @override |
| 48 visitParenthesizedExpression(ParenthesizedExpression node) { |
| 49 super.visitParenthesizedExpression(node); |
| 50 node.staticType = node.expression.staticType; |
| 51 } |
| 52 |
| 53 @override |
48 visitForEachStatement(ForEachStatement node) { | 54 visitForEachStatement(ForEachStatement node) { |
49 // Visit other children. | 55 // Visit other children. |
50 node.iterable.accept(this); | 56 node.iterable.accept(this); |
51 node.body.accept(this); | 57 node.body.accept(this); |
52 | 58 |
53 // If needed, assert a cast inside the body before the variable is read. | 59 // If needed, assert a cast inside the body before the variable is read. |
54 var variable = node.identifier ?? node.loopVariable.identifier; | 60 var variable = node.identifier ?? node.loopVariable.identifier; |
55 var coercion = CoercionInfo.get(variable); | 61 var coercion = CoercionInfo.get(variable); |
56 if (coercion is DownCast) { | 62 if (coercion is DownCast) { |
57 // Build the cast. We will place this cast in the body, so need to clone | 63 // Build the cast. We will place this cast in the body, so need to clone |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 157 |
152 @override | 158 @override |
153 ExpressionFunctionBody visitExpressionFunctionBody( | 159 ExpressionFunctionBody visitExpressionFunctionBody( |
154 ExpressionFunctionBody node) { | 160 ExpressionFunctionBody node) { |
155 var clone = super.visitExpressionFunctionBody(node); | 161 var clone = super.visitExpressionFunctionBody(node); |
156 (clone as FunctionBodyImpl).localVariableInfo = | 162 (clone as FunctionBodyImpl).localVariableInfo = |
157 (node as FunctionBodyImpl).localVariableInfo; | 163 (node as FunctionBodyImpl).localVariableInfo; |
158 return clone; | 164 return clone; |
159 } | 165 } |
160 } | 166 } |
OLD | NEW |