| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.resolver; | 5 library analyzer.src.generated.resolver; |
| 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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 7566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7577 return; | 7577 return; |
| 7578 } | 7578 } |
| 7579 // prepare current variable type | 7579 // prepare current variable type |
| 7580 DartType type = _promoteManager.getType(element) ?? | 7580 DartType type = _promoteManager.getType(element) ?? |
| 7581 expression.staticType ?? | 7581 expression.staticType ?? |
| 7582 DynamicTypeImpl.instance; | 7582 DynamicTypeImpl.instance; |
| 7583 | 7583 |
| 7584 potentialType ??= DynamicTypeImpl.instance; | 7584 potentialType ??= DynamicTypeImpl.instance; |
| 7585 | 7585 |
| 7586 // Check if we can promote to potentialType from type. | 7586 // Check if we can promote to potentialType from type. |
| 7587 if (typeSystem.canPromoteToType(potentialType, type)) { | 7587 DartType promoteType = typeSystem.tryPromoteToType(potentialType, type); |
| 7588 if (promoteType != null) { |
| 7588 // Do promote type of variable. | 7589 // Do promote type of variable. |
| 7589 _promoteManager.setType(element, potentialType); | 7590 _promoteManager.setType(element, promoteType); |
| 7590 } | 7591 } |
| 7591 } | 7592 } |
| 7592 } | 7593 } |
| 7593 | 7594 |
| 7594 /** | 7595 /** |
| 7595 * Promotes type information using given condition. | 7596 * Promotes type information using given condition. |
| 7596 */ | 7597 */ |
| 7597 void _promoteTypes(Expression condition) { | 7598 void _promoteTypes(Expression condition) { |
| 7598 if (condition is BinaryExpression) { | 7599 if (condition is BinaryExpression) { |
| 7599 if (condition.operator.type == TokenType.AMPERSAND_AMPERSAND) { | 7600 if (condition.operator.type == TokenType.AMPERSAND_AMPERSAND) { |
| (...skipping 3673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11273 return null; | 11274 return null; |
| 11274 } | 11275 } |
| 11275 if (identical(node.staticElement, variable)) { | 11276 if (identical(node.staticElement, variable)) { |
| 11276 if (node.inSetterContext()) { | 11277 if (node.inSetterContext()) { |
| 11277 result = true; | 11278 result = true; |
| 11278 } | 11279 } |
| 11279 } | 11280 } |
| 11280 return null; | 11281 return null; |
| 11281 } | 11282 } |
| 11282 } | 11283 } |
| OLD | NEW |