mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 02:39:20 +00:00
chore: remove unnecessary params
This commit is contained in:
parent
1deb0c4788
commit
5c6ea316f5
13 changed files with 220 additions and 372 deletions
|
@ -538,12 +538,11 @@ impl Context {
|
|||
qnames: &Set<Str>,
|
||||
loc: &impl Locational,
|
||||
) -> TyCheckResult<Type> {
|
||||
let allow_cast = true;
|
||||
if self.is_trait(&super_t) {
|
||||
self.check_trait_impl(&sub_t, &super_t, &set! {}, loc)?;
|
||||
}
|
||||
// REVIEW: Even if type constraints can be satisfied, implementation may not exist
|
||||
if self.subtype_of(&sub_t, &super_t, allow_cast) {
|
||||
if self.subtype_of(&sub_t, &super_t) {
|
||||
let sub_t = if cfg!(feature = "debug") {
|
||||
sub_t
|
||||
} else {
|
||||
|
@ -559,7 +558,7 @@ impl Context {
|
|||
Variance::Contravariant => Ok(super_t),
|
||||
Variance::Invariant => {
|
||||
// need to check if sub_t == super_t
|
||||
if self.supertype_of(&sub_t, &super_t, allow_cast) {
|
||||
if self.supertype_of(&sub_t, &super_t) {
|
||||
Ok(sub_t)
|
||||
} else {
|
||||
Err(TyCheckErrors::from(TyCheckError::subtyping_error(
|
||||
|
@ -856,9 +855,8 @@ impl Context {
|
|||
}
|
||||
|
||||
pub(crate) fn trait_impl_exists(&self, class: &Type, trait_: &Type) -> bool {
|
||||
let allow_cast = true;
|
||||
// `Never` implements any trait
|
||||
if self.subtype_of(class, &Type::Never, allow_cast) {
|
||||
if self.subtype_of(class, &Type::Never) {
|
||||
return true;
|
||||
}
|
||||
if class.is_monomorphic() {
|
||||
|
@ -869,11 +867,10 @@ impl Context {
|
|||
}
|
||||
|
||||
fn mono_class_trait_impl_exist(&self, class: &Type, trait_: &Type) -> bool {
|
||||
let allow_cast = true;
|
||||
let mut super_exists = false;
|
||||
for inst in self.get_trait_impls(trait_).into_iter() {
|
||||
if self.supertype_of(&inst.sub_type, class, allow_cast)
|
||||
&& self.supertype_of(&inst.sup_trait, trait_, allow_cast)
|
||||
if self.supertype_of(&inst.sub_type, class)
|
||||
&& self.supertype_of(&inst.sup_trait, trait_)
|
||||
{
|
||||
super_exists = true;
|
||||
break;
|
||||
|
@ -883,11 +880,10 @@ impl Context {
|
|||
}
|
||||
|
||||
fn poly_class_trait_impl_exists(&self, class: &Type, trait_: &Type) -> bool {
|
||||
let allow_cast = true;
|
||||
let mut super_exists = false;
|
||||
for inst in self.get_trait_impls(trait_).into_iter() {
|
||||
if self.supertype_of(&inst.sub_type, class, allow_cast)
|
||||
&& self.supertype_of(&inst.sup_trait, trait_, allow_cast)
|
||||
if self.supertype_of(&inst.sub_type, class)
|
||||
&& self.supertype_of(&inst.sup_trait, trait_)
|
||||
{
|
||||
super_exists = true;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue