| 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 } | 668 } |
| 669 | 669 |
| 670 void _checkRuntimeTypeCheck(AstNode node, TypeName typeName) { | 670 void _checkRuntimeTypeCheck(AstNode node, TypeName typeName) { |
| 671 var type = getType(typeName); | 671 var type = getType(typeName); |
| 672 if (!_rules.isGroundType(type)) { | 672 if (!_rules.isGroundType(type)) { |
| 673 _recordMessage(new InvalidRuntimeCheckError(node, type)); | 673 _recordMessage(new InvalidRuntimeCheckError(node, type)); |
| 674 } | 674 } |
| 675 } | 675 } |
| 676 | 676 |
| 677 visitAsExpression(AsExpression node) { | 677 visitAsExpression(AsExpression node) { |
| 678 // We could do the same check as the IsExpression below, but that is |
| 679 // potentially too conservative. Instead, at runtime, we must fail hard |
| 680 // if the Dart as and the DDC as would return different values. |
| 678 node.visitChildren(this); | 681 node.visitChildren(this); |
| 679 } | 682 } |
| 680 | 683 |
| 681 visitIsExpression(IsExpression node) { | 684 visitIsExpression(IsExpression node) { |
| 682 _checkRuntimeTypeCheck(node, node.type); | 685 _checkRuntimeTypeCheck(node, node.type); |
| 683 node.visitChildren(this); | 686 node.visitChildren(this); |
| 684 } | 687 } |
| 685 | 688 |
| 686 DartType getType(TypeName name) { | 689 DartType getType(TypeName name) { |
| 687 return (name == null) ? _rules.provider.dynamicType : name.type; | 690 return (name == null) ? _rules.provider.dynamicType : name.type; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 void _recordDynamicInvoke(AstNode node) { | 776 void _recordDynamicInvoke(AstNode node) { |
| 774 _reporter.log(new DynamicInvoke(_rules, node)); | 777 _reporter.log(new DynamicInvoke(_rules, node)); |
| 775 } | 778 } |
| 776 | 779 |
| 777 void _recordMessage(StaticInfo info) { | 780 void _recordMessage(StaticInfo info) { |
| 778 if (info == null) return; | 781 if (info == null) return; |
| 779 if (info.level >= logger.Level.SEVERE) _failure = true; | 782 if (info.level >= logger.Level.SEVERE) _failure = true; |
| 780 _reporter.log(info); | 783 _reporter.log(info); |
| 781 } | 784 } |
| 782 } | 785 } |
| OLD | NEW |