Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1848)

Unified Diff: pkg/kernel/lib/type_environment.dart

Issue 2849213002: Add a strong mode implementation of LUB to fasta; use it to infer ?: (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698