Issue 43717. Update UP(FunctionType, unrelated) to UP(Object, unrelated).
Bug: https://github.com/dart-lang/sdk/issues/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>
diff --git a/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart b/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
index 27eceab..4bc97f5 100644
--- a/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
+++ b/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
@@ -667,10 +667,14 @@
return _functionType(T1, T2);
}
- // UP(T Function<...>(...), T2) = Object
- // UP(T1, T Function<...>(...)) = Object
- if (T1 is FunctionType || T2 is FunctionType) {
- return _typeSystem.objectNone;
+ // UP(T Function<...>(...), T2) = UP(Object, T2)
+ if (T1 is FunctionType) {
+ return getLeastUpperBound(_typeSystem.objectNone, T2);
+ }
+
+ // UP(T1, T Function<...>(...)) = UP(T1, Object)
+ if (T2 is FunctionType) {
+ return getLeastUpperBound(T1, _typeSystem.objectNone);
}
// UP(T1, T2) = T2 if T1 <: T2
diff --git a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
index cda9e13..3c9c633 100644
--- a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
+++ b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
@@ -2000,6 +2000,20 @@
);
}
}
+
+ test_unrelated() {
+ var T1 = functionTypeNone(returnType: intNone);
+
+ _checkLeastUpperBound(T1, intNone, objectNone);
+ _checkLeastUpperBound(T1, intQuestion, objectQuestion);
+ _checkLeastUpperBound(T1, intStar, objectStar);
+
+ _checkLeastUpperBound(
+ T1,
+ futureOrNone(functionQuestion),
+ objectQuestion,
+ );
+ }
}
@reflectiveTest