iter 22b.3.6: call-site rewrite — same/cross module qualified names

This commit is contained in:
2026-05-09 21:07:58 +02:00
parent e8018d48b6
commit d1b590ceab
3 changed files with 271 additions and 2 deletions
+34
View File
@@ -442,3 +442,37 @@ fn fixpoint_handles_chained_class_method_calls() {
— multi-round fixpoint property"
);
}
/// After the mono pass, the body of `main` in
/// test_22b2_instance_present must reference `show#Int` instead
/// of `show`.
#[test]
fn rewrite_replaces_class_method_var_with_mono_symbol_same_module() {
let entry = examples_dir().join("test_22b2_instance_present.ail.json");
let ws = ailang_core::load_workspace(&entry).expect("load");
let diags = ailang_check::check_workspace(&ws);
assert!(diags.is_empty(), "fixture must typecheck: {:?}", diags);
let ws = ailang_check::monomorphise_workspace(&ws).expect("mono");
let main_module = ws.modules.get("test_22b2_instance_present").unwrap();
let main_fn = main_module
.defs
.iter()
.find_map(|d| match d {
ailang_core::ast::Def::Fn(f) if f.name == "main" => Some(f),
_ => None,
})
.expect("main");
// The body is `App { fn: Var "show", args: [Lit 42] }`. After
// rewrite, the callee Var must be `show#Int`.
let callee_name: &str = match &main_fn.body {
ailang_core::ast::Term::App { callee, .. } => match callee.as_ref() {
ailang_core::ast::Term::Var { name } => name.as_str(),
other => panic!("callee is not Var: {:?}", other),
},
other => panic!("body is not App: {:?}", other),
};
assert_eq!(callee_name, "show#Int");
}