diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java index f7f0c7bf..02e4801d 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java @@ -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); } }