mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
fix: declaration bugs
This commit is contained in:
parent
14b26a7f4d
commit
6c3536cc31
16 changed files with 275 additions and 61 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue