diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 7e6b942b18..1da990eb3c 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -1608,15 +1608,14 @@ impl<'db> Type<'db> { "__self__" => Symbol::bound(bound_method.self_instance(db)), "__func__" => Symbol::bound(Type::FunctionLiteral(bound_method.function(db))), _ => { - let member = KnownClass::MethodType.to_instance(db).member(db, name); - - // If an attribute is not available on the bound method object, it will be looked - // up on the underlying function object: - if member.is_unbound() { - Type::FunctionLiteral(bound_method.function(db)).member(db, name) - } else { - member - } + KnownClass::MethodType + .to_instance(db) + .member(db, name) + .or_fall_back_to(db, || { + // If an attribute is not available on the bound method object, + // it will be looked up on the underlying function object: + Type::FunctionLiteral(bound_method.function(db)).member(db, name) + }) } }, Type::Callable(CallableType::MethodWrapperDunderGet(_)) => {