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

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

Issue 1975753004: use GLB function in strong mode inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: comments Created 4 years, 7 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/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 877944a9b0552d36feacf99c253d719f8702a243..b1d8b416213947d247aa05e3ce9b1673bf74dda9 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -1330,18 +1330,13 @@ class _StrongInferenceTypeSystem extends StrongTypeSystemImpl {
if (t1 is TypeParameterType) {
_TypeParameterBound bound = _bounds[t1];
if (bound != null) {
- _GuardedSubtypeChecker<DartType> guardedSubtype = _guard(_isSubtypeOf);
-
- DartType newUpper = t2;
- if (guardedSubtype(bound.upper, newUpper, visited)) {
- // upper bound already covers this. Nothing to do.
- } else if (guardedSubtype(newUpper, bound.upper, visited)) {
- // update to the new, more precise upper bound.
- bound.upper = newUpper;
- } else {
- // Failed to find an upper bound. Use bottom to signal no solution.
- bound.upper = BottomTypeImpl.instance;
- }
+ // Ensure T1 <: T2, where T1 is a type parameter we are inferring.
+ // T2 is an upper bound, so merge it with our existing upper bound.
+ //
+ // We already know T1 <: U, for some U.
+ // So update U to reflect the new constraint T1 <: GLB(U, T2)
+ //
+ bound.upper = getGreatestLowerBound(_typeProvider, bound.upper, t2);
// Optimistically assume we will be able to satisfy the constraint.
return true;
}
@@ -1349,6 +1344,12 @@ class _StrongInferenceTypeSystem extends StrongTypeSystemImpl {
if (t2 is TypeParameterType) {
_TypeParameterBound bound = _bounds[t2];
if (bound != null) {
+ // Ensure T1 <: T2, where T2 is a type parameter we are inferring.
+ // T1 is a lower bound, so merge it with our existing lower bound.
+ //
+ // We already know L <: T2, for some L.
+ // So update L to reflect the new constraint LUB(L, T1) <: T2
+ //
bound.lower = getLeastUpperBound(_typeProvider, bound.lower, t1);
// Optimistically assume we will be able to satisfy the constraint.
return true;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698