feat: add Generic Resolver for Records
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 4m54s

This commit is contained in:
Ruben 2024-11-29 13:50:09 +01:00
parent b9f9994de3
commit 24bf3d350f

View File

@ -9,6 +9,7 @@ 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.FieldAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
@ -100,6 +101,7 @@ public class TYPE {
public ConstraintSet addRecursiveParameterConstraints(RecordPattern recordPattern, TypeInferenceBlockInformation blockInformation){
ConstraintSet constraintSet = new ConstraintSet();
System.out.println("TEST");
var subPatternList = recordPattern.getSubPattern();
int counter = 0;
@ -115,8 +117,17 @@ public class TYPE {
for (ClassOrInterface allClass : allClasses) {
var className = allClass.getClassName().getClassName();
if(className.equals(typename)){
var resolver = new GenericsResolverSameName();
FormalParameter param = (FormalParameter) allClass.getConstructors().getFirst().getParameterList().getParameterAt(counter);
FieldAssumption assumption = new FieldAssumption(param.getName(), allClass, param.getType(), blockInformation.getCurrentTypeScope());
RefTypeOrTPHOrWildcardOrGeneric receiverType = assumption.getReceiverType(resolver);
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(), receiverType == null ? type : receiverType, PairOperator.SMALLERDOT, new SourceLoc(blockInformation.getCurrentClass().getFileName(), el.getOffset().getLine())));
}
}