This commit is contained in:
2026-03-24 13:40:33 +00:00
parent 2ba8507284
commit a4cc1487c4
8 changed files with 48 additions and 126 deletions
+20 -5
View File
@@ -192,17 +192,32 @@ impl ExportRef {
}
}
/// Canonical function key, identifying an overload by arity only (for now).
/// This will be extended in PR-03.04 with types and calling convention.
/// Canonical function identity.
///
/// JVM-like canonical pieces to uniquely identify an overload across projects:
/// - `owner`: optional service/type name for methods (e.g., `Some("Log")`) or `None` for free fns
/// - `name`: unqualified function/method name (e.g., `"debug"`)
/// - `sig`: canonical signature id produced by the frontend
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct CanonicalFnKey {
pub import: ImportRef,
pub arity: u16,
pub owner: Option<ItemName>,
pub name: ItemName,
pub sig: SignatureRef,
}
impl CanonicalFnKey {
pub fn new(import: ImportRef, arity: u16) -> Self { Self { import, arity } }
pub fn new(owner: Option<ItemName>, name: ItemName, sig: SignatureRef) -> Self {
Self { owner, name, sig }
}
/// Returns a human-friendly display name like "Log.debug" or just "debug".
pub fn debug_name(&self) -> String {
match &self.owner {
Some(o) => format!("{}.{}", o.as_str(), self.name.as_str()),
None => self.name.as_str().to_string(),
}
}
}
/// Opaque canonical reference to a type known to the Frontend.