Index: pkg/kernel/lib/type_environment.dart |
diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart |
index 8db70bb9374718e1cfe62a83712dddcc7f1021d5..edefd06aee3a2058eb41122d63b5497ce07dbdec 100644 |
--- a/pkg/kernel/lib/type_environment.dart |
+++ b/pkg/kernel/lib/type_environment.dart |
@@ -143,17 +143,22 @@ abstract class SubtypeTester { |
InterfaceType get rawFunctionType; |
ClassHierarchy get hierarchy; |
+ /// Determines if the given type is at the bottom of the type hierarchy. May |
+ /// be overridden in subclasses. |
+ bool isBottom(DartType type) => type is BottomType; |
ahe
2017/05/02 18:32:57
This is Null, right?
Paul Berry
2017/05/03 17:31:25
I discussed this with Leaf yesterday. The intenti
|
+ |
+ /// Determines if the given type is at the top of the type hierarchy. May be |
+ /// overridden in subclasses. |
+ bool isTop(DartType type) => |
+ type is DynamicType || type is VoidType || type == objectType; |
+ |
/// Returns true if [subtype] is a subtype of [supertype]. |
bool isSubtypeOf(DartType subtype, DartType supertype) { |
subtype = subtype.unalias; |
supertype = supertype.unalias; |
if (identical(subtype, supertype)) return true; |
- if (subtype is BottomType) return true; |
- if (supertype is DynamicType || |
- supertype is VoidType || |
- supertype == objectType) { |
- return true; |
- } |
+ if (isBottom(subtype)) return true; |
+ if (isTop(supertype)) return true; |
if (subtype is InterfaceType && supertype is InterfaceType) { |
var upcastType = |
hierarchy.getTypeAsInstanceOf(subtype, supertype.classNode); |