From 58fa180a069cef9692f002cb5b5eb401d6c90d0b Mon Sep 17 00:00:00 2001 From: bd-912 Date: Fri, 10 May 2024 13:03:12 -0600 Subject: Fixed many issues with overloading in extensions --- st/ClassInstance.java | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'st/ClassInstance.java') diff --git a/st/ClassInstance.java b/st/ClassInstance.java index d96d3d5..a794f96 100644 --- a/st/ClassInstance.java +++ b/st/ClassInstance.java @@ -1,6 +1,7 @@ package st; import java.util.ArrayList; +import misc.*; public class ClassInstance extends AbstractInstance { private ClassInstance ext; // the name of the extended class (null if none) @@ -15,8 +16,29 @@ public class ClassInstance extends AbstractInstance { @Override public boolean equals(Object other) { ClassInstance o; - return (other instanceof ClassInstance && - ((o = (ClassInstance) other).getName() == this.getName())); + if (other instanceof ClassInstance) + o = (ClassInstance) other; + else + return false; + + if (o.getName().equals(this.getName())) + return true; + else + MinimalLogger.info(String.format("I (%s) do not have the same name as %s... Checking if I extend...", + this.getName(), o.getName())); + + if (this.getExtend() == null) { + MinimalLogger.info(String.format("I (%s) do not extend anything!", this.getName())); + return false; + } + + ClassInstance te = this.getExtend(); + if (te.equals(o)) { + MinimalLogger.info(String.format("I (%s) extends %s!", this.getName(), o.getName())); + return true; + } + MinimalLogger.info(String.format("I (%s) do not extend %s! I extend %s instead.", this.getName(), o.getName(), te.getName())); + return false; } public ClassInstance getExtend() { -- cgit v1.2.3