Polymorphism Fixes #104

Merged
sb10q merged 1 commits from polymorphism_fixes into master 2024-08-17 17:37:19 +08:00
2 changed files with 6 additions and 4 deletions
Showing only changes of commit 49476d06e1 - Show all commits

View File

@ -148,8 +148,9 @@ impl ConcreteTypeStore {
.borrow()
.iter()
.filter_map(|(name, ty)| {
// filter out functions as they can have type vars and
// will not affect codegen
// here we should not have type vars, but some partial instantiated
// class methods can still have uninstantiated type vars, so
Outdated
Review

What does this comment mean? Did you mean "cannot have type vars..."?

What does this comment mean? Did you mean "cannot have type vars..."?

Yes, here since we are concretizing types, all class fields should not have type vars. But due to partial instantiation of class methods, there might still be some methods whose signature contains type vars. So I filter out all the functions here since class methods here does not affect codegen.

I will put clearer comments here in a later commit.

Yes, here since we are concretizing types, all class fields should not have type vars. But due to partial instantiation of class methods, there might still be some methods whose signature contains type vars. So I filter out all the functions here since class methods here does not affect codegen. I will put clearer comments here in a later commit.
// filter out all the methods, as this will not affect codegen
if let TypeEnum::TFunc( .. ) = &*unifier.get_ty(ty.0) {
None
} else {

View File

@ -725,8 +725,9 @@ impl Unifier {
if let TypeEnum::TVar { id, range, .. } =
self.unification_table.probe_value(*v).as_ref()
{
// need to do this for partial instantiated function
// (in class methods that contains type vars not in class)
// for class methods that contain type vars not in class declaration,
Outdated
Review

to do what?

to do what?

To change the way to check whether a function is instantiated (e.g., as long as there exits one uninstantiated type var, the function is not instantiated)

Thanks for pointing it out, I will also put clearer comments here in a later commit.

To change the way to check whether a function is instantiated (e.g., as long as there exits one uninstantiated type var, the function is not instantiated) Thanks for pointing it out, I will also put clearer comments here in a later commit.
// as long as there exits one uninstantiated type var, the function is not instantiated,
// and need to do substitution on those type vars
if k == id {
instantiated = false;
vars.push((*k, range.clone()));