| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.typechecker; | 5 library dart2js.typechecker; |
| 6 | 6 |
| 7 import 'common.dart'; | 7 import 'common.dart'; |
| 8 import 'common/names.dart' show | 8 import 'common/names.dart' show |
| 9 Identifiers; | 9 Identifiers; |
| 10 import 'common/resolution.dart' show | 10 import 'common/resolution.dart' show |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 551 } |
| 552 | 552 |
| 553 /** | 553 /** |
| 554 * Check if a value of type [from] can be assigned to a variable, parameter or | 554 * Check if a value of type [from] can be assigned to a variable, parameter or |
| 555 * return value of type [to]. If `isConst == true`, an error is emitted in | 555 * return value of type [to]. If `isConst == true`, an error is emitted in |
| 556 * checked mode, otherwise a warning is issued. | 556 * checked mode, otherwise a warning is issued. |
| 557 */ | 557 */ |
| 558 bool checkAssignable(Spannable spannable, DartType from, DartType to, | 558 bool checkAssignable(Spannable spannable, DartType from, DartType to, |
| 559 {bool isConst: false}) { | 559 {bool isConst: false}) { |
| 560 if (!types.isAssignable(from, to)) { | 560 if (!types.isAssignable(from, to)) { |
| 561 if (compiler.enableTypeAssertions && isConst) { | 561 if (compiler.options.enableTypeAssertions && isConst) { |
| 562 reporter.reportErrorMessage( | 562 reporter.reportErrorMessage( |
| 563 spannable, | 563 spannable, |
| 564 MessageKind.NOT_ASSIGNABLE, | 564 MessageKind.NOT_ASSIGNABLE, |
| 565 {'fromType': from, 'toType': to}); | 565 {'fromType': from, 'toType': to}); |
| 566 } else { | 566 } else { |
| 567 reporter.reportWarningMessage( | 567 reporter.reportWarningMessage( |
| 568 spannable, | 568 spannable, |
| 569 MessageKind.NOT_ASSIGNABLE, | 569 MessageKind.NOT_ASSIGNABLE, |
| 570 {'fromType': from, 'toType': to}); | 570 {'fromType': from, 'toType': to}); |
| 571 } | 571 } |
| (...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 | 2004 |
| 2005 visitTypedef(Typedef node) { | 2005 visitTypedef(Typedef node) { |
| 2006 // Do not typecheck [Typedef] nodes. | 2006 // Do not typecheck [Typedef] nodes. |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 visitNode(Node node) { | 2009 visitNode(Node node) { |
| 2010 reporter.internalError(node, | 2010 reporter.internalError(node, |
| 2011 'Unexpected node ${node.getObjectDescription()} in the type checker.'); | 2011 'Unexpected node ${node.getObjectDescription()} in the type checker.'); |
| 2012 } | 2012 } |
| 2013 } | 2013 } |
| OLD | NEW |