Skip to main content

resolve_library_extension

Function resolve_library_extension 

Source
fn resolve_library_extension<'hir>(
    gcx: Gcx<'hir>,
    hir: &Hir<'hir>,
    method_name: Symbol,
    arg_count: usize,
    receiver_ty: Ty<'hir>,
) -> Vec<FunctionId>
Expand description

Finds library functions in the HIR that could be a using for extension matching the given method name, call arity, and receiver type. A library extension function has arg_count + 1 parameters (the extra one being the receiver passed implicitly) with the first parameter in storage, and that first parameter’s type must structurally match the receiver’s static type, otherwise an unrelated library with a same-named function would false-positive on a contract/interface call.

Solar does not yet embed resolution info on ExprKind::Member for extension methods, so this is a best-effort fallback. The per-name lookup table is memoized per HIR (see library_extensions_by_name) to avoid a full function_ids() scan on every eligible call.