Skip to main content

disambiguate_method_name

Function disambiguate_method_name 

Source
pub fn disambiguate_method_name(
    cased_name: String,
    field_names: &HashSet<String>,
    suffix: &str,
) -> String
Expand description

Disambiguate a method’s emitted name against the type’s field names.

cased_name is the method name already mapped through the backend’s casing rule (so the comparison is apples-to-apples with the field_names produced by collect_record_field_names using the same casing). When the cased method name is also a field name, the method is renamed by appending suffix directly to the cased name — the suffix is the backend’s already-cased disambiguator ("Method" for Go’s Pascal and js/ts’s camel, "_method" for Python’s snake), so message/Message become messageMethod/MessageMethod/message_method. The cased prefix is left untouched (no re-casing), so camelCase names with internal capitals survive intact. Non-colliding names pass through unchanged.

Backends call this identically at the method declaration and at every call site, so the renamed method always resolves.