Skip to content

Commit 7fedb2c

Browse files
committed
Avoid union return type for ambiguous overload match
1 parent 504a19d commit 7fedb2c

File tree

1 file changed

+4
-15
lines changed
  • crates/ty_python_semantic/src/types/call

1 file changed

+4
-15
lines changed

crates/ty_python_semantic/src/types/call/bind.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,18 +1395,7 @@ impl<'db> CallableBinding<'db> {
13951395

13961396
if !are_return_types_equivalent_for_all_matching_overloads {
13971397
// Overload matching is ambiguous.
1398-
self.overload_call_return_type = Some(OverloadCallReturnType::Ambiguous(
1399-
IntersectionBuilder::new(db)
1400-
.positive_elements([
1401-
Type::any(),
1402-
UnionType::from_elements(
1403-
db,
1404-
self.matching_overloads()
1405-
.map(|(_, overload)| overload.return_type()),
1406-
),
1407-
])
1408-
.build(),
1409-
));
1398+
self.overload_call_return_type = Some(OverloadCallReturnType::Ambiguous);
14101399
}
14111400
}
14121401

@@ -1486,8 +1475,8 @@ impl<'db> CallableBinding<'db> {
14861475
pub(crate) fn return_type(&self) -> Type<'db> {
14871476
if let Some(overload_call_return_type) = self.overload_call_return_type {
14881477
return match overload_call_return_type {
1489-
OverloadCallReturnType::ArgumentTypeExpansion(return_type)
1490-
| OverloadCallReturnType::Ambiguous(return_type) => return_type,
1478+
OverloadCallReturnType::ArgumentTypeExpansion(return_type) => return_type,
1479+
OverloadCallReturnType::Ambiguous => Type::any(),
14911480
};
14921481
}
14931482
if let Some((_, first_overload)) = self.matching_overloads().next() {
@@ -1641,7 +1630,7 @@ impl<'a, 'db> IntoIterator for &'a CallableBinding<'db> {
16411630
#[derive(Debug, Copy, Clone)]
16421631
enum OverloadCallReturnType<'db> {
16431632
ArgumentTypeExpansion(Type<'db>),
1644-
Ambiguous(Type<'db>),
1633+
Ambiguous,
16451634
}
16461635

16471636
#[derive(Debug)]

0 commit comments

Comments
 (0)