toString() doesn't return the class name, see #353
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 5m18s

This commit is contained in:
Daniel Holle 2024-11-27 12:57:58 +01:00
parent f0287c4611
commit b9f9994de3

View File

@ -7,6 +7,7 @@ import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.statement.Statement; import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
@ -106,15 +107,15 @@ public class TYPE {
if(el instanceof RecordPattern){ if(el instanceof RecordPattern){
constraintSet.addAll(addRecursiveParameterConstraints((RecordPattern) el, blockInformation)); constraintSet.addAll(addRecursiveParameterConstraints((RecordPattern) el, blockInformation));
}else{ }else if (recordPattern.getType() instanceof RefType refType){
var allClasses = blockInformation.getAvailableClasses(); var allClasses = blockInformation.getAvailableClasses();
RefTypeOrTPHOrWildcardOrGeneric type; RefTypeOrTPHOrWildcardOrGeneric type;
var typename = refType.getName().getClassName();
for (ClassOrInterface allClass : allClasses) { for (ClassOrInterface allClass : allClasses) {
var typename = recordPattern.getType().toString();
var className = allClass.getClassName().getClassName(); var className = allClass.getClassName().getClassName();
if(className.equals(typename)){ 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()))); constraintSet.addUndConstraint(new Pair(el.getType(), type, PairOperator.SMALLERDOT, new SourceLoc(blockInformation.getCurrentClass().getFileName(), el.getOffset().getLine())));
} }
} }