nac3core: remove unnecessary inline and function parameters

This commit is contained in:
ychenfo 2021-08-27 16:38:42 +08:00
parent 22a728833d
commit 236989defc
2 changed files with 4 additions and 7 deletions

View File

@ -491,8 +491,7 @@ impl TopLevelComposer {
// push self to the ancestors // push self to the ancestors
class_ancestors.push(make_self_type_annotation( class_ancestors.push(make_self_type_annotation(
&temp_def_list, &temp_def_list,
class_id, class_id
self.unifier.borrow_mut(),
)?) )?)
} }
Ok(()) Ok(())
@ -867,7 +866,7 @@ impl TopLevelComposer {
}; };
type_var_to_concrete_def.insert( type_var_to_concrete_def.insert(
dummy_func_arg.ty, dummy_func_arg.ty,
make_self_type_annotation(temp_def_list, *class_id, unifier)?, make_self_type_annotation(temp_def_list, *class_id)?,
); );
result.push(dummy_func_arg); result.push(dummy_func_arg);
} }
@ -926,7 +925,7 @@ impl TopLevelComposer {
let dummy_return_type = unifier.get_fresh_var().0; let dummy_return_type = unifier.get_fresh_var().0;
type_var_to_concrete_def.insert( type_var_to_concrete_def.insert(
dummy_return_type, dummy_return_type,
make_self_type_annotation(temp_def_list, *class_id, unifier)?, make_self_type_annotation(temp_def_list, *class_id)?,
); );
dummy_return_type dummy_return_type
} }

View File

@ -222,7 +222,6 @@ pub fn get_type_from_type_annotation_kinds(
/// the first return is the duplicated type \ /// the first return is the duplicated type \
/// the second return is the var_id of the duplicated type \ /// the second return is the var_id of the duplicated type \
/// the third return is the var_id of the original type /// the third return is the var_id of the original type
#[inline]
pub fn duplicate_type_var(unifier: &mut Unifier, type_var: Type) -> (Type, u32, u32) { pub fn duplicate_type_var(unifier: &mut Unifier, type_var: Type) -> (Type, u32, u32) {
let ty = unifier.get_ty(type_var); let ty = unifier.get_ty(type_var);
if let TypeEnum::TVar { id, range, .. } = ty.as_ref() { if let TypeEnum::TVar { id, range, .. } = ty.as_ref() {
@ -255,8 +254,7 @@ pub fn duplicate_type_var(unifier: &mut Unifier, type_var: Type) -> (Type, u32,
/// and unify them with the class generic `T`, `V` /// and unify them with the class generic `T`, `V`
pub fn make_self_type_annotation( pub fn make_self_type_annotation(
top_level_defs: &[Arc<RwLock<TopLevelDef>>], top_level_defs: &[Arc<RwLock<TopLevelDef>>],
def_id: DefinitionId, def_id: DefinitionId
_unifier: &mut Unifier,
) -> Result<TypeAnnotation, String> { ) -> Result<TypeAnnotation, String> {
let obj_def = let obj_def =
top_level_defs.get(def_id.0).ok_or_else(|| "invalid definition id".to_string())?; top_level_defs.get(def_id.0).ok_or_else(|| "invalid definition id".to_string())?;