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

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

Issue 2618393002: Insert covariance checks in strong mode. (Closed)
Patch Set: Merge Created 3 years, 11 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
« no previous file with comments | « pkg/kernel/lib/type_algebra.dart ('k') | pkg/kernel/test/baseline_strong_mode_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « pkg/kernel/lib/type_algebra.dart ('k') | pkg/kernel/test/baseline_strong_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698