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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 2208233002: Make LUB algorithm aware of non-null types (Closed) Base URL: https://github.com/dart-lang/sdk@nnp
Patch Set: Fix logic bug in isNullableType Created 4 years, 4 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 | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index df190085af056ab3edface93eaaf5be38d19a1cd..2c59228796fe5cf96fea8c7be536a8a734ec750f 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -1957,11 +1957,19 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
sj.add(j);
// compute intersection, reference as set 's'
List<InterfaceType> s = _intersection(si, sj);
+ return computeTypeAtMaxUniqueDepth(s);
+ }
+
+ /**
+ * Return the type from the [types] list that has the longest inheritence path
+ * to Object of unique length.
+ */
+ static InterfaceType computeTypeAtMaxUniqueDepth(List<InterfaceType> types) {
// for each element in Set s, compute the largest inheritance path to Object
- List<int> depths = new List<int>.filled(s.length, 0);
+ List<int> depths = new List<int>.filled(types.length, 0);
int maxDepth = 0;
- for (int n = 0; n < s.length; n++) {
- depths[n] = computeLongestInheritancePathToObject(s[n]);
+ for (int n = 0; n < types.length; n++) {
+ depths[n] = computeLongestInheritancePathToObject(types[n]);
if (depths[n] > maxDepth) {
maxDepth = depths[n];
}
@@ -1978,7 +1986,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}
}
if (numberOfTypesAtMaxDepth == 1) {
- return s[indexOfLeastUpperBound];
+ return types[indexOfLeastUpperBound];
}
}
// Should be impossible--there should always be exactly one type with the
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698