Prevent instance attributes from shadowing typed capability methods

This commit is contained in:
2026-10-22 15:28:19 +08:00
parent c96dce118b
commit 0513b96dfb
7 changed files with 349 additions and 4 deletions
+7
View File
@@ -12,6 +12,9 @@ pub struct ObjectStore {
pub(crate) heap: Heap,
function_type: Option<WeakObjectRef>,
pub(crate) field_type_checks: bool,
pub(crate) active_attribute_checks: std::sync::Mutex<
std::collections::HashMap<std::thread::ThreadId, std::collections::BTreeSet<ObjectRef>>,
>,
pub(crate) active_trait_checks: std::sync::Mutex<
std::collections::HashMap<
std::thread::ThreadId,
@@ -157,6 +160,7 @@ impl ObjectStore {
heap: Heap::new()?,
function_type: None,
field_type_checks: false,
active_attribute_checks: std::sync::Mutex::new(std::collections::HashMap::new()),
active_trait_checks: std::sync::Mutex::new(std::collections::HashMap::new()),
})
}
@@ -312,6 +316,9 @@ impl ObjectStore {
if self.field_type_checks {
self.check_field_write(reference, &name, &value)?;
}
for object in self.attribute_path(reference)? {
self.check_typed_method_write(object, &name)?;
}
let storage = *self
.attribute_path(reference)?
.last()