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

Unified Diff: pkg/analyzer/lib/src/generated/type_system.dart

Issue 2208233002: Make LUB algorithm aware of non-null types (Closed) Base URL: https://github.com/dart-lang/sdk@nnp
Patch Set: 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
Index: pkg/analyzer/lib/src/generated/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index 91541323a8df0568de33fadcfa1434d60a80157c..4d36ec9b39c2a8e15229c3e88b5b79d2ce5ca3fa 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -142,6 +142,23 @@ class StrongTypeSystemImpl extends TypeSystem {
}
/**
+ * Compute the least upper bound of two types.
+ */
+ @override
+ DartType getLeastUpperBound(
+ TypeProvider typeProvider, DartType type1, DartType type2) {
+ // The least upper bound of bottom and any nonnullable type T is dynamic.
+ if (type1.isBottom && isNonNullableType(type2)) {
Leaf 2016/08/03 23:45:07 This depends a bit on exactly what system you are
stanm 2016/08/04 00:31:15 Thanks for the detailed explanation. If by 'My gu
Leaf 2016/08/04 19:40:36 Looks right to me. LNST(T)? == LNST(T), I think,
+ return typeProvider.dynamicType;
+ }
+ if (type2.isBottom && isNonNullableType(type1)) {
+ return typeProvider.dynamicType;
+ }
+ return super.getLeastUpperBound(typeProvider, type1, type2);
+ }
+
+
+ /**
* Given a generic function type `F<T0, T1, ... Tn>` and a context type C,
* infer an instantiation of F, such that `F<S0, S1, ..., Sn>` <: C.
*
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | pkg/analyzer/lib/src/task/strong/checker.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698