Re-shuffle Obj::type_inst and BaseObjInst::type_inst

There was a moment during the refactor that I was thinking about getting
rid of the `__type__` attribute as the source of truth for the type
instance, but I think that was a bit more than I could chew. However I
forgot to re-add the default implementation for Obj::type_inst, so that
has been added back in.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-09-25 10:27:53 -07:00
parent 2203957ebb
commit 38a2064b08
2 changed files with 3 additions and 9 deletions

View File

@@ -238,7 +238,9 @@ pub trait Obj: Debug + Display + Any + Trace {
} }
} }
fn type_inst(&self) -> ObjP; fn type_inst(&self) -> ObjP {
self.get_attr("__type__").expect("no __type__")
}
fn type_name(&self) -> Rc<String> { fn type_name(&self) -> Rc<String> {
with_obj_downcast(self.type_inst(), |type_inst: &TypeInst| { with_obj_downcast(self.type_inst(), |type_inst: &TypeInst| {
@@ -313,10 +315,6 @@ impl Obj for BaseObjInst {
&mut self.attrs &mut self.attrs
} }
fn type_inst(&self) -> ObjP {
self.get_attr("__type__").expect("no __type__")
}
fn equals(&self, other: &dyn Obj) -> bool { fn equals(&self, other: &dyn Obj) -> bool {
if let Some(other) = other.as_any().downcast_ref::<BaseObjInst>() { if let Some(other) = other.as_any().downcast_ref::<BaseObjInst>() {
// compare all attrs // compare all attrs

View File

@@ -23,10 +23,6 @@ macro_rules! impl_base_obj {
self.$base_name.attrs_mut() self.$base_name.attrs_mut()
} }
fn type_inst(&self) -> ObjP {
self.$base_name.type_inst()
}
fn as_any(&self) -> &dyn std::any::Any { fn as_any(&self) -> &dyn std::any::Any {
self self
} }