From b9f9994de383ea01d3e26a621b85da80c6f5268a Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Wed, 27 Nov 2024 12:57:58 +0100 Subject: [PATCH] toString() doesn't return the class name, see #353 --- .../java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java index 55984ef1..8aa68f07 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java @@ -7,6 +7,7 @@ import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.statement.Statement; +import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -106,15 +107,15 @@ public class TYPE { if(el instanceof RecordPattern){ constraintSet.addAll(addRecursiveParameterConstraints((RecordPattern) el, blockInformation)); - }else{ + }else if (recordPattern.getType() instanceof RefType refType){ var allClasses = blockInformation.getAvailableClasses(); RefTypeOrTPHOrWildcardOrGeneric type; + var typename = refType.getName().getClassName(); for (ClassOrInterface allClass : allClasses) { - var typename = recordPattern.getType().toString(); var className = allClass.getClassName().getClassName(); if(className.equals(typename)){ - type = allClass.getConstructors().get(0).getParameterList().getParameterAt(counter).getType(); + type = allClass.getConstructors().getFirst().getParameterList().getParameterAt(counter).getType(); constraintSet.addUndConstraint(new Pair(el.getType(), type, PairOperator.SMALLERDOT, new SourceLoc(blockInformation.getCurrentClass().getFileName(), el.getOffset().getLine()))); } }