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 library dev_compiler.src.checker.checker; | 5 library dev_compiler.src.checker.checker; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
10 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; | 10 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 break; | 737 break; |
738 case TokenType.BANG_EQ: | 738 case TokenType.BANG_EQ: |
739 break; | 739 break; |
740 default: | 740 default: |
741 assert(false); | 741 assert(false); |
742 } | 742 } |
743 } | 743 } |
744 node.visitChildren(this); | 744 node.visitChildren(this); |
745 } | 745 } |
746 | 746 |
747 @override | |
748 void visitIndexExpression(IndexExpression node) { | |
749 if (_rules.isDynamicTarget(node.target)) { | |
750 _recordDynamicInvoke(node); | |
751 } else { | |
752 var element = node.staticElement; | |
753 if (element is MethodElement) { | |
754 var type = element.type as FunctionType; | |
755 node.index = checkArgument(node.index, type.normalParameterTypes[0]); | |
Leaf
2015/06/02 23:59:11
Analyzer should catch bad arity, but probably stil
Jennifer Messerly
2015/06/03 00:06:54
hmmm, good catch. Guess I should fix visitBinaryEx
| |
756 } else { | |
757 // TODO(vsm): Assert that the analyzer found an error here? | |
758 } | |
759 } | |
760 node.visitChildren(this); | |
761 } | |
762 | |
747 DartType getType(TypeName name) { | 763 DartType getType(TypeName name) { |
748 return (name == null) ? _rules.provider.dynamicType : name.type; | 764 return (name == null) ? _rules.provider.dynamicType : name.type; |
749 } | 765 } |
750 | 766 |
751 Expression checkAssignment(Expression expr, DartType type) { | 767 Expression checkAssignment(Expression expr, DartType type) { |
752 if (expr is ParenthesizedExpression) { | 768 if (expr is ParenthesizedExpression) { |
753 expr.expression = checkAssignment(expr.expression, type); | 769 expr.expression = checkAssignment(expr.expression, type); |
754 } else { | 770 } else { |
755 final staticInfo = _rules.checkAssignment(expr, type, _constantContext); | 771 final staticInfo = _rules.checkAssignment(expr, type, _constantContext); |
756 _recordMessage(staticInfo); | 772 _recordMessage(staticInfo); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 void _recordDynamicInvoke(AstNode node) { | 856 void _recordDynamicInvoke(AstNode node) { |
841 _reporter.log(new DynamicInvoke(_rules, node)); | 857 _reporter.log(new DynamicInvoke(_rules, node)); |
842 } | 858 } |
843 | 859 |
844 void _recordMessage(StaticInfo info) { | 860 void _recordMessage(StaticInfo info) { |
845 if (info == null) return; | 861 if (info == null) return; |
846 if (info.level >= logger.Level.SEVERE) _failure = true; | 862 if (info.level >= logger.Level.SEVERE) _failure = true; |
847 _reporter.log(info); | 863 _reporter.log(info); |
848 } | 864 } |
849 } | 865 } |
OLD | NEW |