let __env = self.env();
let __obj = match self.obj(&__env) {
    Ok(o) => o,
{% if has_default_impl %}
    // Object disposed/unavailable — treat like a missing method (no-op default).
    Err(_) => return {% if has_error %}Ok(()){% else %}Default::default(){% endif %},
{% elif has_error %}
    Err(e) => return Err({{ error_lookup }}),
{% else %}
    Err(_) => return Default::default(),
{% endif %}
};
let func: napi::bindgen_prelude::Function<{{ args_tuple_ty }}, napi::bindgen_prelude::Unknown> = match __obj.get_named_property("{{ method_name }}")
    .or_else(|_| __obj.get_named_property("{{ snake_case_method_name }}")) {
    Ok(f) => f,
{% if has_default_impl %}
    // Method has a default impl on the Rust trait — treat missing JS property as a no-op
    // (the foreign object opted out of overriding it).
    Err(_) => return {% if has_error %}Ok(()){% else %}Default::default(){% endif %},
{% elif has_error %}
    Err(e) => return Err({{ error_lookup }}),
{% else %}
    Err(_) => return Default::default(),
{% endif %}
};

{% if empty_args %}
let result = func.call(());
{% else %}
let result = func.call(napi::bindgen_prelude::FnArgs::from({{ tuple_args }}));
{% endif %}

{% if has_error %}
match result {
    Err(e) => Err({{ error_call }}),
    Ok(_) => Ok(())
}
{% else %}
match result {
    Err(_) => Default::default(),
    Ok(_) => ()
}
{% endif %}
