Fix get_attr_lazy
I had misunderstood/misused the ? suffix operator for the Option type. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -256,6 +256,7 @@ pub trait Obj: Debug + Display + Any + Trace {
|
|||||||
|
|
||||||
let mut type_inst = self.type_inst();
|
let mut type_inst = self.type_inst();
|
||||||
loop {
|
loop {
|
||||||
|
let vtable_entry =
|
||||||
with_obj_downcast_mut(type_inst.clone(), |type_inst: &mut TypeInst| {
|
with_obj_downcast_mut(type_inst.clone(), |type_inst: &mut TypeInst| {
|
||||||
type_inst.vtable.get(name).cloned()
|
type_inst.vtable.get(name).cloned()
|
||||||
})
|
})
|
||||||
@@ -269,7 +270,10 @@ pub trait Obj: Debug + Display + Any + Trace {
|
|||||||
};
|
};
|
||||||
self.set_attr(name, ptr.clone());
|
self.set_attr(name, ptr.clone());
|
||||||
ptr
|
ptr
|
||||||
})?;
|
});
|
||||||
|
if vtable_entry.is_some() {
|
||||||
|
return vtable_entry;
|
||||||
|
}
|
||||||
let type_inst_copy = type_inst.borrow().type_inst();
|
let type_inst_copy = type_inst.borrow().type_inst();
|
||||||
if type_inst.borrow().equals(&*type_inst_copy.borrow()) {
|
if type_inst.borrow().equals(&*type_inst_copy.borrow()) {
|
||||||
return None;
|
return None;
|
||||||
@@ -1158,6 +1162,7 @@ fn test_obj_equals() {
|
|||||||
assert!(obj2.borrow().equals(&*obj1.borrow()));
|
assert!(obj2.borrow().equals(&*obj1.borrow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
fn test_obj_vtable() {
|
fn test_obj_vtable() {
|
||||||
let mut builtins = HashMap::new();
|
let mut builtins = HashMap::new();
|
||||||
init_types(&mut builtins);
|
init_types(&mut builtins);
|
||||||
|
|||||||
Reference in New Issue
Block a user