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

Unified Diff: pkg/compiler/lib/src/world.dart

Issue 1338683002: Add related types check to analyze_dart2js_test (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 3 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/compiler/lib/src/use_unused_api.dart ('k') | pkg/js_ast/lib/src/printer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/world.dart
diff --git a/pkg/compiler/lib/src/world.dart b/pkg/compiler/lib/src/world.dart
index b8925b3bbe61dd5abac70488952b7e2516edc109..6cfa45f9700bf74ff7d9ffbc36b8351f07834fe1 100644
--- a/pkg/compiler/lib/src/world.dart
+++ b/pkg/compiler/lib/src/world.dart
@@ -89,6 +89,9 @@ abstract class ClassWorld {
/// including [cls] if it is live.
Iterable<ClassElement> strictSubtypesOf(ClassElement cls);
+ /// Returns `true` if [a] and [b] have any known common subtypes.
+ bool haveAnyCommonSubtypes(ClassElement a, ClassElement b);
+
/// Returns `true` if any live class other than [cls] extends [cls].
bool hasAnyStrictSubclass(ClassElement cls);
@@ -216,6 +219,21 @@ class World implements ClassWorld {
}
}
+ /// Returns `true` if [a] and [b] have any known common subtypes.
+ bool haveAnyCommonSubtypes(ClassElement a, ClassElement b) {
+ ClassSet classSetA = _classSets[a.declaration];
+ ClassSet classSetB = _classSets[b.declaration];
+ if (classSetA == null || classSetB == null) return false;
+ // TODO(johnniwinther): Implement an optimized query on [ClassSet].
+ Set<ClassElement> subtypesOfB = classSetB.subtypes().toSet();
+ for (ClassElement subtypeOfA in classSetA.subtypes()) {
+ if (subtypesOfB.contains(subtypeOfA)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/// Returns `true` if any directly instantiated class other than [cls] extends
/// [cls].
bool hasAnyStrictSubclass(ClassElement cls) {
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | pkg/js_ast/lib/src/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698