From abda2c4c4119bca8b738abc9231b6d89b8922236 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Tue, 9 Jun 2026 17:25:27 +0200 Subject: [PATCH] Working override target --- crates/codegen/src/class_decl.rs | 6 ++---- mist-test/src/items/class_test.mist | 10 +++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/codegen/src/class_decl.rs b/crates/codegen/src/class_decl.rs index 76769f3..176baed 100644 --- a/crates/codegen/src/class_decl.rs +++ b/crates/codegen/src/class_decl.rs @@ -231,9 +231,7 @@ impl ClassProcessedData { } fn emit_super_v_tests(&self, cg: &mut RustCodegen) { - for (idx, (override_tier, _)) in - self.override_v_table.iter().enumerate() - { + for (idx, (override_tier, _)) in self.override_v_table.iter().enumerate() { // Resolve the target path for this specific sub-table let target_path = match &override_tier.0 { // Override(Some(path)) / Override::Path(path) -> Targets deep ancestor @@ -380,7 +378,7 @@ impl ClassProcessedData { // Deep ancestor trait table updates Some(path) => { cg.add_indentedln(&format!( - "<{} as std::ops::Deref>::deref(&this)._m_oop.0 = Self::__SUPER_V_TABLES[{}];", + "(|v: &mut {}| {{v._m_oop.0 = Self::__SUPER_V_TABLES[{}];}})(&mut this);", path.get_rust(), idx )); diff --git a/mist-test/src/items/class_test.mist b/mist-test/src/items/class_test.mist index ae85717..076571d 100644 --- a/mist-test/src/items/class_test.mist +++ b/mist-test/src/items/class_test.mist @@ -15,7 +15,15 @@ pub class Animal { } } -pub class Dog : Animal { +pub class Mammal : Animal { + constructor() { + unsafe { + std::ptr::write(&mut super, Super::new()); + } + } +} + +pub class Dog : Mammal { constructor() { unsafe { std::ptr::write(&mut super, Super::new());