| 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 /// Encapsulates how to invoke the analyzer resolver and overrides how it | 5 /// Encapsulates how to invoke the analyzer resolver and overrides how it |
| 6 /// computes types on expressions to use our restricted set of types. | 6 /// computes types on expressions to use our restricted set of types. |
| 7 library dev_compiler.src.checker.resolver; | 7 library dev_compiler.src.checker.resolver; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 317 |
| 318 bool _canInferFrom(Expression expression) { | 318 bool _canInferFrom(Expression expression) { |
| 319 if (expression is Literal) return true; | 319 if (expression is Literal) return true; |
| 320 if (expression is InstanceCreationExpression) return true; | 320 if (expression is InstanceCreationExpression) return true; |
| 321 if (expression is FunctionExpression) return true; | 321 if (expression is FunctionExpression) return true; |
| 322 if (expression is AsExpression) return true; | 322 if (expression is AsExpression) return true; |
| 323 if (expression is CascadeExpression) { | 323 if (expression is CascadeExpression) { |
| 324 return _canInferFrom(expression.target); | 324 return _canInferFrom(expression.target); |
| 325 } | 325 } |
| 326 if (expression is SimpleIdentifier || expression is PropertyAccess) { | 326 if (expression is SimpleIdentifier || expression is PropertyAccess) { |
| 327 return _options.inferStaticsFromIdentifiers; | 327 return _options.inferTransitively; |
| 328 } | 328 } |
| 329 if (expression is PrefixedIdentifier) { | 329 if (expression is PrefixedIdentifier) { |
| 330 if (expression.staticElement is PropertyAccessorElement) { | 330 if (expression.staticElement is PropertyAccessorElement) { |
| 331 return _options.inferStaticsFromIdentifiers; | 331 return _options.inferTransitively; |
| 332 } | 332 } |
| 333 return _canInferFrom(expression.identifier); | 333 return _canInferFrom(expression.identifier); |
| 334 } | 334 } |
| 335 if (expression is MethodInvocation) { | 335 if (expression is MethodInvocation) { |
| 336 return _canInferFrom(expression.target); | 336 return _canInferFrom(expression.target); |
| 337 } | 337 } |
| 338 if (expression is BinaryExpression) { | 338 if (expression is BinaryExpression) { |
| 339 return _canInferFrom(expression.leftOperand); | 339 return _canInferFrom(expression.leftOperand); |
| 340 } | 340 } |
| 341 if (expression is ConditionalExpression) { | 341 if (expression is ConditionalExpression) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 // Review note: no longer need to override visitFunctionExpression, this is | 525 // Review note: no longer need to override visitFunctionExpression, this is |
| 526 // handled by the analyzer internally. | 526 // handled by the analyzer internally. |
| 527 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? | 527 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? |
| 528 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression | 528 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression |
| 529 // type in a (...) => expr or just the written type? | 529 // type in a (...) => expr or just the written type? |
| 530 | 530 |
| 531 } | 531 } |
| OLD | NEW |