| 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 /// Defines static information collected by the type checker and used later by | 5 /// Defines static information collected by the type checker and used later by |
| 6 /// emitters to generate code. | 6 /// emitters to generate code. |
| 7 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be | 7 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be |
| 8 // refactored to fit into analyzer. | 8 // refactored to fit into analyzer. |
| 9 library analyzer.src.task.strong.info; | 9 library analyzer.src.task.strong.info; |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 : super(rules, expression) { | 89 : super(rules, expression) { |
| 90 assert(_cast.toType != baseType && | 90 assert(_cast.toType != baseType && |
| 91 _cast.fromType == baseType && | 91 _cast.fromType == baseType && |
| 92 (baseType.isDynamic || | 92 (baseType.isDynamic || |
| 93 // Call methods make the following non-redundant | 93 // Call methods make the following non-redundant |
| 94 _cast.toType.isSubtypeOf(baseType) || | 94 _cast.toType.isSubtypeOf(baseType) || |
| 95 baseType.isAssignableTo(_cast.toType))); | 95 baseType.isAssignableTo(_cast.toType))); |
| 96 } | 96 } |
| 97 | 97 |
| 98 @override | 98 @override |
| 99 List<Object> get arguments => [node, baseType, convertedType]; | 99 List<Object> get arguments => [baseType, convertedType]; |
| 100 | 100 |
| 101 Cast get cast => _cast; | 101 Cast get cast => _cast; |
| 102 | 102 |
| 103 DartType get convertedType => _cast.toType; | 103 DartType get convertedType => _cast.toType; |
| 104 |
| 104 @override | 105 @override |
| 105 String get message => '{0} ({1}) will need runtime check ' | 106 String get message => 'Unsound implicit cast from {0} to {1}'; |
| 106 'to cast to type {2}'; | |
| 107 | 107 |
| 108 // Factory to create correct DownCast variant. | 108 // Factory to create correct DownCast variant. |
| 109 static StaticInfo create( | 109 static StaticInfo create( |
| 110 StrongTypeSystemImpl rules, Expression expression, Cast cast, | 110 StrongTypeSystemImpl rules, Expression expression, Cast cast, |
| 111 {String reason}) { | 111 {String reason}) { |
| 112 final fromT = cast.fromType; | 112 final fromT = cast.fromType; |
| 113 final toT = cast.toType; | 113 final toT = cast.toType; |
| 114 | 114 |
| 115 // toT <:_R fromT => to <: fromT | 115 // toT <:_R fromT => to <: fromT |
| 116 // NB: classes with call methods are subtypes of function | 116 // NB: classes with call methods are subtypes of function |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 // TODO(vsm,leafp): Remove this. | 578 // TODO(vsm,leafp): Remove this. |
| 579 class UninferredClosure extends DownCast { | 579 class UninferredClosure extends DownCast { |
| 580 UninferredClosure(TypeSystem rules, FunctionExpression expression, Cast cast) | 580 UninferredClosure(TypeSystem rules, FunctionExpression expression, Cast cast) |
| 581 : super._internal(rules, expression, cast); | 581 : super._internal(rules, expression, cast); |
| 582 | 582 |
| 583 @override | 583 @override |
| 584 String get name => 'STRONG_MODE_UNINFERRED_CLOSURE'; | 584 String get name => 'STRONG_MODE_UNINFERRED_CLOSURE'; |
| 585 | 585 |
| 586 toErrorCode() => new StaticTypeWarningCode(name, message); | 586 toErrorCode() => new StaticTypeWarningCode(name, message); |
| 587 } | 587 } |
| OLD | NEW |