Index: pkg/kernel/lib/type_environment.dart |
diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart |
index 9bf931828c7896d701c78bb668005161e2977d98..0b90cb4ba4742ec9856090ba65121553b44aaebf 100644 |
--- a/pkg/kernel/lib/type_environment.dart |
+++ b/pkg/kernel/lib/type_environment.dart |
@@ -118,6 +118,21 @@ class TypeEnvironment extends SubtypeTester { |
if (type1 == doubleType || type2 == doubleType) return doubleType; |
return numType; |
} |
+ |
+ /// Returns true if [class_] has no proper subtypes that are usable as type |
+ /// argument. |
+ bool isSealedClass(Class class_) { |
+ // The sealed core classes have subtypes in the patched SDK, but those |
+ // classes cannot occur as type argument. |
+ if (class_ == coreTypes.intClass || |
+ class_ == coreTypes.doubleClass || |
+ class_ == coreTypes.stringClass || |
+ class_ == coreTypes.boolClass || |
+ class_ == coreTypes.nullClass) { |
+ return true; |
+ } |
+ return !hierarchy.hasProperSubtypes(class_); |
+ } |
} |
/// The part of [TypeEnvironment] that deals with subtype tests. |