Skip to content

Commit a44db26

Browse files
committed
Rename MatchingOverload -> MatchingOverloadIndex
1 parent 0a5077b commit a44db26

File tree

1 file changed

+29
-24
lines changed
  • crates/ty_python_semantic/src/types/call

1 file changed

+29
-24
lines changed

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

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,8 @@ impl<'db> CallableBinding<'db> {
11161116
let argument_types = argument_types.with_self(self.bound_type);
11171117

11181118
// Step 1: Check the result of the arity check which is done by `match_parameters`
1119-
match self.matching_overload() {
1120-
MatchingOverload::None => {
1119+
match self.matching_overload_index() {
1120+
MatchingOverloadIndex::None => {
11211121
// If no candidate overloads remain from the arity check, we can stop here. We
11221122
// still perform type checking for non-overloaded function to provide better user
11231123
// experience.
@@ -1126,7 +1126,7 @@ impl<'db> CallableBinding<'db> {
11261126
}
11271127
return;
11281128
}
1129-
MatchingOverload::Single(index) => {
1129+
MatchingOverloadIndex::Single(index) => {
11301130
// If only one candidate overload remains, it is the winning match.
11311131
self.overloads.get_mut(index).unwrap().check_types(
11321132
db,
@@ -1135,7 +1135,7 @@ impl<'db> CallableBinding<'db> {
11351135
);
11361136
return;
11371137
}
1138-
MatchingOverload::Multiple(_) => {
1138+
MatchingOverloadIndex::Multiple(_) => {
11391139
// If two or more candidate overloads remain, proceed to step 2.
11401140
}
11411141
}
@@ -1148,15 +1148,15 @@ impl<'db> CallableBinding<'db> {
11481148
overload.check_types(db, argument_types.as_ref(), argument_types.types());
11491149
}
11501150

1151-
match self.matching_overload() {
1152-
MatchingOverload::None => {
1151+
match self.matching_overload_index() {
1152+
MatchingOverloadIndex::None => {
11531153
// If all overloads result in errors, proceed to step 3.
11541154
}
1155-
MatchingOverload::Single(_) => {
1155+
MatchingOverloadIndex::Single(_) => {
11561156
// If only one overload evaluates without error, it is the winning match.
11571157
return;
11581158
}
1159-
MatchingOverload::Multiple(_) => {
1159+
MatchingOverloadIndex::Multiple(_) => {
11601160
// If two or more candidate overloads remain, proceed to step 4.
11611161
// TODO: Step 4 and Step 5 goes here...
11621162
// We're returning here because this shouldn't lead to argument type expansion.
@@ -1187,10 +1187,12 @@ impl<'db> CallableBinding<'db> {
11871187
overload.check_types(db, argument_types.as_ref(), expanded_argument_types);
11881188
}
11891189

1190-
let return_type = match self.matching_overload() {
1191-
MatchingOverload::None => None,
1192-
MatchingOverload::Single(index) => Some(self.overloads[index].return_type()),
1193-
MatchingOverload::Multiple(index) => {
1190+
let return_type = match self.matching_overload_index() {
1191+
MatchingOverloadIndex::None => None,
1192+
MatchingOverloadIndex::Single(index) => {
1193+
Some(self.overloads[index].return_type())
1194+
}
1195+
MatchingOverloadIndex::Multiple(index) => {
11941196
// TODO: Step 4 and Step 5 goes here... but for now we just use the return
11951197
// type of the first matched overload.
11961198
Some(self.overloads[index].return_type())
@@ -1258,22 +1260,16 @@ impl<'db> CallableBinding<'db> {
12581260
self.matching_overloads().next().is_none()
12591261
}
12601262

1261-
/// Returns the index of the only matching overload in the form of [`MatchingOverload`].
1262-
///
1263-
/// If there are no matching overloads, returns [`MatchingOverload::None`].
1264-
/// If there are multiple matching overloads, returns [`MatchingOverload::Multiple`] with the
1265-
/// index of the first matching overload.
1266-
/// If there is exactly one matching overload, returns [`MatchingOverload::Single`] with the
1267-
/// index of that overload.
1268-
fn matching_overload(&self) -> MatchingOverload {
1263+
/// Returns the index of the matching overload in the form of [`MatchingOverloadIndex`].
1264+
fn matching_overload_index(&self) -> MatchingOverloadIndex {
12691265
let mut matching_overloads = self.matching_overloads();
12701266
match matching_overloads.next() {
1271-
None => MatchingOverload::None,
1267+
None => MatchingOverloadIndex::None,
12721268
Some((index, _)) => {
12731269
if matching_overloads.next().is_some() {
1274-
MatchingOverload::Multiple(index)
1270+
MatchingOverloadIndex::Multiple(index)
12751271
} else {
1276-
MatchingOverload::Single(index)
1272+
MatchingOverloadIndex::Single(index)
12771273
}
12781274
}
12791275
}
@@ -1453,9 +1449,18 @@ impl<'a, 'db> IntoIterator for &'a CallableBinding<'db> {
14531449
}
14541450

14551451
#[derive(Debug)]
1456-
enum MatchingOverload {
1452+
enum MatchingOverloadIndex {
1453+
/// No matching overloads found.
14571454
None,
1455+
1456+
/// Exactly one matching overload found.
1457+
///
1458+
/// The index is the position of the matching overload.
14581459
Single(usize),
1460+
1461+
/// Multiple matching overloads found.
1462+
///
1463+
/// The index is the position of the first matching overload.
14591464
Multiple(usize),
14601465
}
14611466

0 commit comments

Comments
 (0)