Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: lib/src/checker/resolver.dart

Issue 1361833002: Screen dynamic invokes to object properties in checker (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Handle object tearoffs better Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/checker/checker.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 689
690 // Search for Object methods. 690 // Search for Object methods.
691 var name = node.methodName.name; 691 var name = node.methodName.name;
692 if (node.staticType.isDynamic && 692 if (node.staticType.isDynamic &&
693 _objectMembers.containsKey(name) && 693 _objectMembers.containsKey(name) &&
694 isDynamicTarget(node.target)) { 694 isDynamicTarget(node.target)) {
695 var type = _objectMembers[name]; 695 var type = _objectMembers[name];
696 if (type is FunctionType && 696 if (type is FunctionType &&
697 type.parameters.isEmpty && 697 type.parameters.isEmpty &&
698 node.argumentList.arguments.isEmpty) { 698 node.argumentList.arguments.isEmpty) {
699 node.target.staticType = _typeProvider.objectType;
700 node.methodName.staticType = type; 699 node.methodName.staticType = type;
701 // Only infer the type of the overall expression if we have an exact 700 // Only infer the type of the overall expression if we have an exact
702 // type - e.g., a sealed type. Otherwise, it may be too strict. 701 // type - e.g., a sealed type. Otherwise, it may be too strict.
703 if (_isSealed(type.returnType)) { 702 if (_isSealed(type.returnType)) {
704 node.staticType = type.returnType; 703 node.staticType = type.returnType;
705 } 704 }
706 } 705 }
707 } 706 }
708 707
709 var e = node.methodName.staticElement; 708 var e = node.methodName.staticElement;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 749 }
751 } 750 }
752 751
753 void _inferObjectAccess( 752 void _inferObjectAccess(
754 Expression node, Expression target, SimpleIdentifier id) { 753 Expression node, Expression target, SimpleIdentifier id) {
755 // Search for Object accesses. 754 // Search for Object accesses.
756 var name = id.name; 755 var name = id.name;
757 if (node.staticType.isDynamic && 756 if (node.staticType.isDynamic &&
758 _objectMembers.containsKey(name) && 757 _objectMembers.containsKey(name) &&
759 isDynamicTarget(target)) { 758 isDynamicTarget(target)) {
760 target.staticType = _typeProvider.objectType;
761 var type = _objectMembers[name]; 759 var type = _objectMembers[name];
762 id.staticType = type; 760 id.staticType = type;
763 // Only infer the type of the overall expression if we have an exact 761 // Only infer the type of the overall expression if we have an exact
764 // type - e.g., a sealed type. Otherwise, it may be too strict. 762 // type - e.g., a sealed type. Otherwise, it may be too strict.
765 if (_isSealed(type)) { 763 if (_isSealed(type)) {
766 node.staticType = type; 764 node.staticType = type;
767 } 765 }
768 } 766 }
769 } 767 }
770 768
(...skipping 30 matching lines...) Expand all
801 } 799 }
802 } 800 }
803 801
804 // Review note: no longer need to override visitFunctionExpression, this is 802 // Review note: no longer need to override visitFunctionExpression, this is
805 // handled by the analyzer internally. 803 // handled by the analyzer internally.
806 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? 804 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result?
807 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression 805 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression
808 // type in a (...) => expr or just the written type? 806 // type in a (...) => expr or just the written type?
809 807
810 } 808 }
OLDNEW
« no previous file with comments | « lib/src/checker/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698