mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 14:04:33 +00:00
Update generalize.rs
This commit is contained in:
parent
010426d475
commit
658ed24482
1 changed files with 15 additions and 21 deletions
|
@ -747,18 +747,22 @@ impl<'c, 'q, 'l, L: Locational> Dereferencer<'c, 'q, 'l, L> {
|
||||||
self.ctx
|
self.ctx
|
||||||
.check_trait_impl(&sub_t, &super_t, self.qnames, self.loc)?;
|
.check_trait_impl(&sub_t, &super_t, self.qnames, self.loc)?;
|
||||||
}
|
}
|
||||||
|
let is_subtype = self.ctx.subtype_of(&sub_t, &super_t);
|
||||||
|
let sub_t = if DEBUG_MODE {
|
||||||
|
sub_t
|
||||||
|
} else {
|
||||||
|
self.deref_tyvar(sub_t)?
|
||||||
|
};
|
||||||
|
let super_t = if DEBUG_MODE {
|
||||||
|
super_t
|
||||||
|
} else {
|
||||||
|
self.deref_tyvar(super_t)?
|
||||||
|
};
|
||||||
|
if sub_t == super_t {
|
||||||
|
Ok(sub_t)
|
||||||
|
}
|
||||||
// REVIEW: Even if type constraints can be satisfied, implementation may not exist
|
// REVIEW: Even if type constraints can be satisfied, implementation may not exist
|
||||||
if self.ctx.subtype_of(&sub_t, &super_t) {
|
else if is_subtype {
|
||||||
let sub_t = if DEBUG_MODE {
|
|
||||||
sub_t
|
|
||||||
} else {
|
|
||||||
self.deref_tyvar(sub_t)?
|
|
||||||
};
|
|
||||||
let super_t = if DEBUG_MODE {
|
|
||||||
super_t
|
|
||||||
} else {
|
|
||||||
self.deref_tyvar(super_t)?
|
|
||||||
};
|
|
||||||
match self.variance {
|
match self.variance {
|
||||||
// ?T(<: Sup) --> Sup (Sup != Obj), because completion will not work if Never is selected.
|
// ?T(<: Sup) --> Sup (Sup != Obj), because completion will not work if Never is selected.
|
||||||
// ?T(:> Never, <: Obj) --> Never
|
// ?T(:> Never, <: Obj) --> Never
|
||||||
|
@ -789,16 +793,6 @@ impl<'c, 'q, 'l, L: Locational> Dereferencer<'c, 'q, 'l, L> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let sub_t = if DEBUG_MODE {
|
|
||||||
sub_t
|
|
||||||
} else {
|
|
||||||
self.deref_tyvar(sub_t)?
|
|
||||||
};
|
|
||||||
let super_t = if DEBUG_MODE {
|
|
||||||
super_t
|
|
||||||
} else {
|
|
||||||
self.deref_tyvar(super_t)?
|
|
||||||
};
|
|
||||||
Err(TyCheckErrors::from(TyCheckError::subtyping_error(
|
Err(TyCheckErrors::from(TyCheckError::subtyping_error(
|
||||||
self.ctx.cfg.input.clone(),
|
self.ctx.cfg.input.clone(),
|
||||||
line!() as usize,
|
line!() as usize,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue