| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 // Fix types for JS builtin calls. | 601 // Fix types for JS builtin calls. |
| 602 // | 602 // |
| 603 // This code was taken from analyzer. It's not super sophisticated: | 603 // This code was taken from analyzer. It's not super sophisticated: |
| 604 // only looks for the type name in dart:core, so we just copy it here. | 604 // only looks for the type name in dart:core, so we just copy it here. |
| 605 // | 605 // |
| 606 // TODO(jmesserly): we'll likely need something that can handle a wider | 606 // TODO(jmesserly): we'll likely need something that can handle a wider |
| 607 // variety of types, especially when we get to JS interop. | 607 // variety of types, especially when we get to JS interop. |
| 608 var args = node.argumentList.arguments; | 608 var args = node.argumentList.arguments; |
| 609 var first = args.isNotEmpty ? args.first : null; | 609 var first = args.isNotEmpty ? args.first : null; |
| 610 if (first is SimpleStringLiteral) { | 610 if (first is SimpleStringLiteral) { |
| 611 var coreLib = _typeProvider.objectType.element.library; | 611 var typeStr = first.stringValue; |
| 612 var classElem = coreLib.getType(first.stringValue); | 612 if (typeStr == '-dynamic') { |
| 613 if (classElem != null) node.staticType = classElem.type; | 613 node.staticType = _typeProvider.bottomType; |
| 614 } else { |
| 615 var coreLib = _typeProvider.objectType.element.library; |
| 616 var classElem = coreLib.getType(typeStr); |
| 617 if (classElem != null) { |
| 618 var type = fillDynamicTypeArgs(classElem.type, _typeProvider); |
| 619 node.staticType = type; |
| 620 } |
| 621 } |
| 614 } | 622 } |
| 615 } | 623 } |
| 616 } | 624 } |
| 617 | 625 |
| 618 void _inferObjectAccess( | 626 void _inferObjectAccess( |
| 619 Expression node, Expression target, SimpleIdentifier id) { | 627 Expression node, Expression target, SimpleIdentifier id) { |
| 620 // Search for Object accesses. | 628 // Search for Object accesses. |
| 621 var name = id.name; | 629 var name = id.name; |
| 622 if (node.staticType.isDynamic && | 630 if (node.staticType.isDynamic && |
| 623 _objectMembers.containsKey(name) && | 631 _objectMembers.containsKey(name) && |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 } | 674 } |
| 667 } | 675 } |
| 668 | 676 |
| 669 // Review note: no longer need to override visitFunctionExpression, this is | 677 // Review note: no longer need to override visitFunctionExpression, this is |
| 670 // handled by the analyzer internally. | 678 // handled by the analyzer internally. |
| 671 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? | 679 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? |
| 672 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression | 680 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression |
| 673 // type in a (...) => expr or just the written type? | 681 // type in a (...) => expr or just the written type? |
| 674 | 682 |
| 675 } | 683 } |
| OLD | NEW |