Skip to content

Commit 562c5e1

Browse files
author
John Messerly
committed
Simplify the bailout test for generic inference
Just tidies up two checks that should be one check, and some vestigial substitution. Noticed this while working on #26992 [email protected] Review URL: https://codereview.chromium.org/2288393002 .
1 parent b63546a commit 562c5e1

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

pkg/analyzer/lib/src/generated/type_system.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,17 +1426,9 @@ class _StrongInferenceTypeSystem extends StrongTypeSystemImpl {
14261426
inferredTypes[i] =
14271427
variance.passedIn || bound.lower.isBottom ? bound.upper : bound.lower;
14281428

1429-
// See if the constraints on the type variable are satisfied.
1430-
//
1431-
// If not, bail out of the analysis, unless a partial solution was
1432-
// requested. If we are willing to accept a partial solution, fall back to
1433-
// the known upper bound (if any) or `dynamic` for this unsolvable type
1434-
// variable.
1435-
if (inferredTypes[i].isBottom ||
1436-
!isSubtypeOf(inferredTypes[i],
1437-
bound.upper.substitute2(inferredTypes, fnTypeParams)) ||
1438-
!isSubtypeOf(bound.lower.substitute2(inferredTypes, fnTypeParams),
1439-
inferredTypes[i])) {
1429+
// See if the bounds can be satisfied.
1430+
if (bound.upper.isBottom ||
1431+
!_typeSystem.isSubtypeOf(bound.lower, bound.upper)) {
14401432
// Inference failed. Bail.
14411433
return null;
14421434
}

0 commit comments

Comments
 (0)