Skip to content

Commit a2ac367

Browse files
committed
Fix singleton class lifecycle invalidation
1 parent 84fdfb6 commit a2ac367

3 files changed

Lines changed: 712 additions & 108 deletions

File tree

rust/rubydex/src/model/declaration.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,14 @@ impl Declaration {
331331
}
332332
}
333333

334+
#[must_use]
335+
pub fn as_singleton_class(&self) -> Option<&Namespace> {
336+
match self {
337+
Declaration::Namespace(ns @ Namespace::SingletonClass(_)) => Some(ns),
338+
_ => None,
339+
}
340+
}
341+
334342
#[must_use]
335343
pub fn as_namespace_mut(&mut self) -> Option<&mut Namespace> {
336344
match self {

rust/rubydex/src/model/definitions.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ impl Definition {
179179
}
180180
}
181181

182+
#[must_use]
183+
pub fn has_extend_mixin(&self) -> bool {
184+
let mixins = match self {
185+
Definition::Class(definition) => definition.mixins(),
186+
Definition::SingletonClass(definition) => definition.mixins(),
187+
Definition::Module(definition) => definition.mixins(),
188+
_ => return false,
189+
};
190+
191+
mixins.iter().any(|mixin| matches!(mixin, Mixin::Extend(_)))
192+
}
193+
182194
#[must_use]
183195
pub fn is_deprecated(&self) -> bool {
184196
all_definitions!(self, it => it.flags().is_deprecated())

0 commit comments

Comments
 (0)