Skip to main content

desugared_optional_method

Function desugared_optional_method 

Source
pub fn desugared_optional_method<'a>(
    call_node: &'a AIRNode,
    callee: &'a AIRNode,
    args: &'a [AirArg],
) -> Option<(&'a AIRNode, &'a str, &'a [AirArg])>
Expand description

Recognise a desugared Optional[T] built-in method call.

Building on desugared_self_call, this additionally requires that (a) the call_node carries the checker’s recv_kind = "Optional" annotation and (b) the method is one of OPTIONAL_METHODS. Returns the receiver node, the method name, and the remaining (non-self) arguments — everything a backend needs to lower the call on the tagged Optional value ((o._tag === "Some" ? o._0 : d) in JS/TS, o._0 if isinstance(o,_BockSome) else d in Python, an __bockOption-tag test in Go, the native method in Rust).

call_node is the full Call AIR node (it holds the annotation); callee and args are its callee/args fields, passed separately so a backend can call this from inside its NodeKind::Call { callee, args, .. } arm.