Work on constraints for parameters of generic records
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 6m14s

This commit is contained in:
Daniel Holle 2024-12-04 12:22:26 +01:00
parent 24bf3d350f
commit d0d9c46a67

View File

@ -101,33 +101,27 @@ public class TYPE {
public ConstraintSet addRecursiveParameterConstraints(RecordPattern recordPattern, TypeInferenceBlockInformation blockInformation){
ConstraintSet constraintSet = new ConstraintSet();
System.out.println("TEST");
var subPatternList = recordPattern.getSubPattern();
var resolver = new GenericsResolverSameName();
int counter = 0;
for(Pattern el : subPatternList){
if(el instanceof RecordPattern){
for (Pattern el : subPatternList){
if (el instanceof RecordPattern){
constraintSet.addAll(addRecursiveParameterConstraints((RecordPattern) el, blockInformation));
}else if (recordPattern.getType() instanceof RefType refType){
} else if (recordPattern.getType() instanceof RefType refType){
var allClasses = blockInformation.getAvailableClasses();
RefTypeOrTPHOrWildcardOrGeneric type;
var typename = refType.getName().getClassName();
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(), receiverType == null ? type : receiverType, PairOperator.SMALLERDOT, new SourceLoc(blockInformation.getCurrentClass().getFileName(), el.getOffset().getLine())));
var fieldCons = new Pair(el.getType(), assumption.getType(resolver), PairOperator.SMALLERDOT);
var recvCons = new Pair(refType, assumption.getReceiverType(resolver), PairOperator.EQUALSDOT);
constraintSet.addUndConstraint(fieldCons);
constraintSet.addUndConstraint(recvCons);
}
}