| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
| 6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
| 7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
| 8 /// | 8 /// |
| 9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
| 10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 // This method assumes the program is correctly typed, so if the superclass | 1240 // This method assumes the program is correctly typed, so if the superclass |
| 1241 // is not generic, we can just return its raw type without computing the | 1241 // is not generic, we can just return its raw type without computing the |
| 1242 // type of this expression. It also ensures that all types are considered | 1242 // type of this expression. It also ensures that all types are considered |
| 1243 // subtypes of Object (not just interface types), and function types are | 1243 // subtypes of Object (not just interface types), and function types are |
| 1244 // considered subtypes of Function. | 1244 // considered subtypes of Function. |
| 1245 if (superclass.typeParameters.isEmpty) { | 1245 if (superclass.typeParameters.isEmpty) { |
| 1246 return superclass.rawType; | 1246 return superclass.rawType; |
| 1247 } | 1247 } |
| 1248 var type = getStaticType(types); | 1248 var type = getStaticType(types); |
| 1249 while (type is TypeParameterType) { | 1249 while (type is TypeParameterType) { |
| 1250 type = type.parameter.bound; | 1250 type = (type as TypeParameterType).parameter.bound; |
| 1251 } | 1251 } |
| 1252 if (type is InterfaceType) { | 1252 if (type is InterfaceType) { |
| 1253 var upcastType = types.hierarchy.getTypeAsInstanceOf(type, superclass); | 1253 var upcastType = types.hierarchy.getTypeAsInstanceOf(type, superclass); |
| 1254 if (upcastType != null) return upcastType; | 1254 if (upcastType != null) return upcastType; |
| 1255 } else if (type is BottomType) { | 1255 } else if (type is BottomType) { |
| 1256 return superclass.bottomType; | 1256 return superclass.bottomType; |
| 1257 } | 1257 } |
| 1258 types.typeError(this, '$type is not a subtype of $superclass'); | 1258 types.typeError(this, '$type is not a subtype of $superclass'); |
| 1259 return superclass.rawType; | 1259 return superclass.rawType; |
| 1260 } | 1260 } |
| (...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3642 | 3642 |
| 3643 @override | 3643 @override |
| 3644 defaultTreeNode(TreeNode node) { | 3644 defaultTreeNode(TreeNode node) { |
| 3645 if (node == child) { | 3645 if (node == child) { |
| 3646 return replacement; | 3646 return replacement; |
| 3647 } else { | 3647 } else { |
| 3648 return node; | 3648 return node; |
| 3649 } | 3649 } |
| 3650 } | 3650 } |
| 3651 } | 3651 } |
| OLD | NEW |