From c9266d971fee67aaaf40a01878638a29b9231d3a Mon Sep 17 00:00:00 2001 From: John Date: Tue, 7 May 2024 13:59:45 -0500 Subject: [PATCH] cl-typeck: Insert impls into target type's namespace TODO: Process imports like this lazily --- compiler/cl-typeck/src/type_resolver.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/cl-typeck/src/type_resolver.rs b/compiler/cl-typeck/src/type_resolver.rs index 7513145..6d6ca45 100644 --- a/compiler/cl-typeck/src/type_resolver.rs +++ b/compiler/cl-typeck/src/type_resolver.rs @@ -272,7 +272,23 @@ impl<'a> TypeResolvable<'a> for &'a Impl { .map_err(|_| "Unresolved type in impl target")?; prj[id].module.parent = Some(target); - + match prj.pool.get_many_mut([id, target]) { + // TODO: Better error handling + Err(_) => Err(concat!( + file!(), + line!(), + column!(), + "id and target are same" + ))?, + Ok([id, target]) => { + for (name, def) in &id.module.types { + target.module.insert_type(*name, *def); + } + for (name, def) in &id.module.values { + target.module.insert_value(*name, *def); + } + } + } Ok(DefKind::Impl(target)) } }