Compare commits

...

2 Commits

Author SHA1 Message Date
4318856fa8 Fix lookup
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 6m20s
2024-12-12 14:21:23 +01:00
1ace099d72 Undo 2024-12-12 14:06:33 +01:00

View File

@ -103,34 +103,31 @@ public class TYPE {
var subPatternList = recordPattern.getSubPattern(); var subPatternList = recordPattern.getSubPattern();
var resolver = new GenericsResolverSameName(); var resolver = new GenericsResolverSameName();
var refType = (RefType) recordPattern.getType();
var allClasses = blockInformation.getAvailableClasses();
var typename = refType.getName().getClassName();
ClassOrInterface allClass = allClasses.stream().filter(c -> c.getClassName().getClassName().equals(typename)).findFirst().orElseThrow();
int counter = 0; int counter = 0;
for (Pattern el : subPatternList){ for (Pattern el : subPatternList){
if (el instanceof RecordPattern){ if (el instanceof RecordPattern){
constraintSet.addAll(addRecursiveParameterConstraints((RecordPattern) el, blockInformation)); constraintSet.addAll(addRecursiveParameterConstraints((RecordPattern) el, blockInformation));
} else if (recordPattern.getType() instanceof RefType refType){ } else {
var allClasses = blockInformation.getAvailableClasses(); FormalParameter param = (FormalParameter) allClass.getConstructors().getFirst().getParameterList().getParameterAt(counter);
var typename = refType.getName().getClassName(); FieldAssumption assumption = new FieldAssumption(param.getName(), allClass, param.getType(), blockInformation.getCurrentTypeScope());
for (ClassOrInterface allClass : allClasses) { var fieldCons = new Pair(el.getType(), assumption.getType(resolver), PairOperator.SMALLERDOT);
var className = allClass.getClassName().getClassName(); var recvCons = new Pair(refType, assumption.getReceiverType(resolver), PairOperator.EQUALSDOT);
if(className.equals(typename)){ constraintSet.addUndConstraint(fieldCons);
FormalParameter param = (FormalParameter) allClass.getConstructors().getFirst().getParameterList().getParameterAt(counter); constraintSet.addUndConstraint(recvCons);
FieldAssumption assumption = new FieldAssumption(param.getName(), allClass, param.getType(), blockInformation.getCurrentTypeScope());
var fieldCons = new Pair(el.getType(), assumption.getType(resolver), PairOperator.EQUALSDOT); for (var i = 0; i < refType.getParaList().size(); i++) {
var recvCons = new Pair(refType, assumption.getReceiverType(resolver), PairOperator.EQUALSDOT); constraintSet.addUndConstraint(new Pair(refType.getParaList().get(i),
constraintSet.addUndConstraint(fieldCons); ((RefType)assumption.getReceiverType(resolver)).getParaList().get(i),
constraintSet.addUndConstraint(recvCons); PairOperator.EQUALSDOT));
for (var i = 0; i < refType.getParaList().size(); i++) {
constraintSet.addUndConstraint(new Pair(refType.getParaList().get(i),
((RefType)assumption.getReceiverType(resolver)).getParaList().get(i),
PairOperator.EQUALSDOT));
}
}
} }
} }
counter++; counter++;
} }