Skip to content

Commit 63e0cd6

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Issue 43717. Update UP(FunctionType, unrelated) to UP(Object, unrelated).
Bug: dart-lang/sdk#43717 Change-Id: Ib2fa861df24d010c768e4a06ba2bff175bbf88f4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166783 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent 057ac51 commit 63e0cd6

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

pkg/analyzer/lib/src/dart/element/least_upper_bound.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,14 @@ class LeastUpperBoundHelper {
667667
return _functionType(T1, T2);
668668
}
669669

670-
// UP(T Function<...>(...), T2) = Object
671-
// UP(T1, T Function<...>(...)) = Object
672-
if (T1 is FunctionType || T2 is FunctionType) {
673-
return _typeSystem.objectNone;
670+
// UP(T Function<...>(...), T2) = UP(Object, T2)
671+
if (T1 is FunctionType) {
672+
return getLeastUpperBound(_typeSystem.objectNone, T2);
673+
}
674+
675+
// UP(T1, T Function<...>(...)) = UP(T1, Object)
676+
if (T2 is FunctionType) {
677+
return getLeastUpperBound(T1, _typeSystem.objectNone);
674678
}
675679

676680
// UP(T1, T2) = T2 if T1 <: T2

pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,20 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase {
20002000
);
20012001
}
20022002
}
2003+
2004+
test_unrelated() {
2005+
var T1 = functionTypeNone(returnType: intNone);
2006+
2007+
_checkLeastUpperBound(T1, intNone, objectNone);
2008+
_checkLeastUpperBound(T1, intQuestion, objectQuestion);
2009+
_checkLeastUpperBound(T1, intStar, objectStar);
2010+
2011+
_checkLeastUpperBound(
2012+
T1,
2013+
futureOrNone(functionQuestion),
2014+
objectQuestion,
2015+
);
2016+
}
20032017
}
20042018

20052019
@reflectiveTest

0 commit comments

Comments
 (0)