fix: declaration bugs

This commit is contained in:
Shunsuke Shibayama 2023-07-31 11:08:53 +09:00
parent 14b26a7f4d
commit 6c3536cc31
16 changed files with 275 additions and 61 deletions

View file

@ -139,6 +139,27 @@ impl ClassDefType {
pub const fn impl_trait(class: Type, impl_trait: Type) -> Self {
ClassDefType::ImplTrait { class, impl_trait }
}
pub fn class(&self) -> &Type {
match self {
ClassDefType::Simple(class) => class,
ClassDefType::ImplTrait { class, .. } => class,
}
}
pub fn is_class_of(&self, t: &Type) -> bool {
match self {
ClassDefType::Simple(class) => class == t,
ClassDefType::ImplTrait { class, .. } => class == t,
}
}
pub fn is_impl_of(&self, trait_: &Type) -> bool {
match self {
ClassDefType::ImplTrait { impl_trait, .. } => impl_trait == trait_,
_ => false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]