| 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 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be | 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be |
| 6 // refactored to fit into analyzer. | 6 // refactored to fit into analyzer. |
| 7 library analyzer.src.task.strong.checker; | 7 library analyzer.src.task.strong.checker; |
| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 _checkReturnOrYield(node.expression, node); | 595 _checkReturnOrYield(node.expression, node); |
| 596 node.visitChildren(this); | 596 node.visitChildren(this); |
| 597 } | 597 } |
| 598 | 598 |
| 599 @override | 599 @override |
| 600 void visitYieldStatement(YieldStatement node) { | 600 void visitYieldStatement(YieldStatement node) { |
| 601 _checkReturnOrYield(node.expression, node, yieldStar: node.star != null); | 601 _checkReturnOrYield(node.expression, node, yieldStar: node.star != null); |
| 602 node.visitChildren(this); | 602 node.visitChildren(this); |
| 603 } | 603 } |
| 604 | 604 |
| 605 @override | 605 void _checkFieldAccess(AstNode node, AstNode target, SimpleIdentifier field) { |
| 606 void visitPropertyAccess(PropertyAccess node) { | 606 if ((rules.isDynamicTarget(target) || field.staticElement == null) && |
| 607 var target = node.realTarget; | 607 !_isObjectProperty(target, field)) { |
| 608 if (rules.isDynamicTarget(target) && | |
| 609 !_isObjectProperty(target, node.propertyName)) { | |
| 610 _recordDynamicInvoke(node, target); | 608 _recordDynamicInvoke(node, target); |
| 611 } | 609 } |
| 612 node.visitChildren(this); | 610 node.visitChildren(this); |
| 613 } | 611 } |
| 614 | 612 |
| 615 @override | 613 @override |
| 616 void visitPrefixedIdentifier(PrefixedIdentifier node) { | 614 void visitPropertyAccess(PropertyAccess node) { |
| 617 final target = node.prefix; | 615 _checkFieldAccess(node, node.realTarget, node.propertyName); |
| 618 if (rules.isDynamicTarget(target) && | |
| 619 !_isObjectProperty(target, node.identifier)) { | |
| 620 _recordDynamicInvoke(node, target); | |
| 621 } | |
| 622 node.visitChildren(this); | |
| 623 } | 616 } |
| 624 | 617 |
| 625 @override | 618 @override |
| 619 void visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 620 _checkFieldAccess(node, node.prefix, node.identifier); |
| 621 } |
| 622 |
| 623 @override |
| 626 void visitDefaultFormalParameter(DefaultFormalParameter node) { | 624 void visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 627 // Check that defaults have the proper subtype. | 625 // Check that defaults have the proper subtype. |
| 628 var parameter = node.parameter; | 626 var parameter = node.parameter; |
| 629 var parameterType = rules.elementType(parameter.element); | 627 var parameterType = rules.elementType(parameter.element); |
| 630 assert(parameterType != null); | 628 assert(parameterType != null); |
| 631 var defaultValue = node.defaultValue; | 629 var defaultValue = node.defaultValue; |
| 632 if (defaultValue != null) { | 630 if (defaultValue != null) { |
| 633 checkAssignment(defaultValue, parameterType); | 631 checkAssignment(defaultValue, parameterType); |
| 634 } | 632 } |
| 635 | 633 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 } | 974 } |
| 977 } catch (e) { | 975 } catch (e) { |
| 978 // TODO(sigmund): remove this try-catch block (see issue #48). | 976 // TODO(sigmund): remove this try-catch block (see issue #48). |
| 979 } | 977 } |
| 980 if (baseMethod == null || baseMethod.isStatic) return null; | 978 if (baseMethod == null || baseMethod.isStatic) return null; |
| 981 return baseMethod.type; | 979 return baseMethod.type; |
| 982 } | 980 } |
| 983 ; | 981 ; |
| 984 return f; | 982 return f; |
| 985 } | 983 } |
| OLD | NEW |