| 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 746 |
| 747 if (!_rules.isSubTypeOf(returnType, lhsType)) { | 747 if (!_rules.isSubTypeOf(returnType, lhsType)) { |
| 748 final numType = _rules.provider.numType; | 748 final numType = _rules.provider.numType; |
| 749 // Try to fix up the numerical case if possible. | 749 // Try to fix up the numerical case if possible. |
| 750 if (_rules.isSubTypeOf(lhsType, numType) && | 750 if (_rules.isSubTypeOf(lhsType, numType) && |
| 751 _rules.isSubTypeOf(lhsType, rhsType)) { | 751 _rules.isSubTypeOf(lhsType, rhsType)) { |
| 752 // This is also slightly different from spec, but allows us to keep | 752 // This is also slightly different from spec, but allows us to keep |
| 753 // compound operators in the int += num and num += dynamic cases. | 753 // compound operators in the int += num and num += dynamic cases. |
| 754 staticInfo = DownCast.create( | 754 staticInfo = DownCast.create( |
| 755 _rules, expr.rightHandSide, Coercion.cast(rhsType, lhsType)); | 755 _rules, expr.rightHandSide, Coercion.cast(rhsType, lhsType)); |
| 756 expr.rightHandSide = staticInfo; | 756 if (staticInfo is DownCast) { |
| 757 expr.rightHandSide = staticInfo; |
| 758 } |
| 757 rhsType = lhsType; | 759 rhsType = lhsType; |
| 758 } else { | 760 } else { |
| 759 // Static type error | 761 // Static type error |
| 760 staticInfo = new StaticTypeError(_rules, expr, lhsType); | 762 staticInfo = new StaticTypeError(_rules, expr, lhsType); |
| 761 } | 763 } |
| 762 _recordMessage(staticInfo); | 764 _recordMessage(staticInfo); |
| 763 } | 765 } |
| 764 | 766 |
| 765 // Check the rhs type | 767 // Check the rhs type |
| 766 if (staticInfo is! Conversion) { | 768 if (staticInfo is! Conversion) { |
| 767 var paramType = paramTypes.first; | 769 var paramType = paramTypes.first; |
| 768 staticInfo = _rules.checkAssignment( | 770 staticInfo = _rules.checkAssignment( |
| 769 expr.rightHandSide, paramType, _constantContext); | 771 expr.rightHandSide, paramType, _constantContext); |
| 770 _recordMessage(staticInfo); | 772 _recordMessage(staticInfo); |
| 771 if (staticInfo is Conversion) expr.rightHandSide = staticInfo; | 773 if (staticInfo is Conversion) expr.rightHandSide = staticInfo; |
| 772 } | 774 } |
| 773 } | 775 } |
| 774 } | 776 } |
| 775 | 777 |
| 776 void _recordDynamicInvoke(AstNode node) { | 778 void _recordDynamicInvoke(AstNode node) { |
| 777 _reporter.log(new DynamicInvoke(_rules, node)); | 779 _reporter.log(new DynamicInvoke(_rules, node)); |
| 778 } | 780 } |
| 779 | 781 |
| 780 void _recordMessage(StaticInfo info) { | 782 void _recordMessage(StaticInfo info) { |
| 781 if (info == null) return; | 783 if (info == null) return; |
| 782 if (info.level >= logger.Level.SEVERE) _failure = true; | 784 if (info.level >= logger.Level.SEVERE) _failure = true; |
| 783 _reporter.log(info); | 785 _reporter.log(info); |
| 784 } | 786 } |
| 785 } | 787 } |
| OLD | NEW |