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 --- heat/HeatVisitor.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'heat/HeatVisitor.java') diff --git a/heat/HeatVisitor.java b/heat/HeatVisitor.java index 9886fdc..2e830c5 100644 --- a/heat/HeatVisitor.java +++ b/heat/HeatVisitor.java @@ -249,10 +249,9 @@ public class HeatVisitor extends GJDepthFirst> // NOT // if it is a class and the classes are equal // or it is not a class and the types are equal - if (!((tb.getInstance() != null && tb.getInstance().equals(_ret.getInstance())) || - (tb.getInstance() == null && tb.getType() == _ret.getType()))) - throw new TypecheckException(String.format("%s returns the wrong type!", - id)); + if (!tb.equals(_ret)) + throw new TypecheckException(String.format("%s in %s returns the wrong type!", + id, symt.getActive(TypeEnum.classname))); /////////////////////////////////////////////////////////////// this.symt.removeActive(TypeEnum.method); MinimalLogger.info(String.format("<- %s (%s)", @@ -327,9 +326,14 @@ public class HeatVisitor extends GJDepthFirst> MinimalLogger.info(String.format("-> %s", n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// - if (n.f0.which == 3) - _ret = new TypeBundle(TypeEnum.classname, this.symt.getClass(((Identifier) n.f0.choice).f0.tokenImage)); - else + if (n.f0.which == 3) { + String id = ((Identifier) n.f0.choice).f0.tokenImage; + ClassInstance c = this.symt.getClass(id); + if (c == null) + throw new TypecheckException(String.format("%s was never declared!", + id)); + _ret = new TypeBundle(TypeEnum.classname, c); + } else _ret = n.f0.accept(this, argu); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", @@ -820,6 +824,8 @@ public class HeatVisitor extends GJDepthFirst> n.getClass().getSimpleName(), t.getName())); + MinimalLogger.severe(String.format("Class instance was: %s", t.getClassInstance())); + MinimalLogger.severe(String.format("M was: %s with args %s", m, m.getParentClass())); ArrayList actual = new ArrayList(); ArrayList expected = new ArrayList(); n.f4.accept(this, actual); -- cgit v1.2.3