mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 03:36:18 +00:00
Small refactor
This commit is contained in:
parent
c09cd6c9d0
commit
962c1f70e1
1 changed files with 6 additions and 19 deletions
|
|
@ -9045,27 +9045,14 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// The reflected dunder has priority if the right-hand side is a strict subclass of the left-hand side.
|
// The reflected dunder has priority if the right-hand side is a strict subclass of the left-hand side.
|
||||||
|
|
||||||
if left != right && right.is_subtype_of(db, left) {
|
if left != right && right.is_subtype_of(db, left) {
|
||||||
let first_call = call_dunder(op.reflect(), right, left);
|
call_dunder(op.reflect(), right, left)
|
||||||
|
.or_else(|e| call_dunder(op, left, right)
|
||||||
match first_call {
|
.map_err(|_| e))
|
||||||
Ok(ty) => Ok(ty),
|
|
||||||
Err(e) => match call_dunder(op, left, right) {
|
|
||||||
Ok(ty) => Ok(ty),
|
|
||||||
Err(_) => Err(e),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let first_call = call_dunder(op, left, right);
|
call_dunder(op, left, right)
|
||||||
|
.or_else(|e| call_dunder(op.reflect(), right, left)
|
||||||
match first_call {
|
.map_err(|_| e))
|
||||||
Ok(ty) => Ok(ty),
|
|
||||||
Err(e) => match call_dunder(op.reflect(), right, left) {
|
|
||||||
Ok(ty) => Ok(ty),
|
|
||||||
Err(_) => Err(e),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.or_else(|e| {
|
.or_else(|e| {
|
||||||
// When no appropriate method returns any value other than NotImplemented,
|
// When no appropriate method returns any value other than NotImplemented,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue