feat: further implementation
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 7m5s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 7m5s
This commit is contained in:
parent
139325e78f
commit
cc8f36d3ec
@ -11,7 +11,6 @@ public class SwitchInfered {
|
|||||||
public main(o) {
|
public main(o) {
|
||||||
return switch (o) {
|
return switch (o) {
|
||||||
case Rec(a, b) -> a;
|
case Rec(a, b) -> a;
|
||||||
case Integer i -> i+1;
|
|
||||||
default -> 0;
|
default -> 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -843,8 +843,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
if (label.getPattern() instanceof RecordPattern) {
|
if (label.getPattern() instanceof RecordPattern) {
|
||||||
RecordPattern recordPattern = (RecordPattern) label.getPattern();
|
RecordPattern recordPattern = (RecordPattern) label.getPattern();
|
||||||
System.out.println("HALFTAN DER WEI?E ICH CHECK ECHT GART NCIHTS MEHR");
|
|
||||||
System.out.println(recordPattern.getName());
|
|
||||||
//constraintsSet.addUndConstraint(new Pair(label.getPattern().getType(), switchStmt.getSwitch().getType(), PairOperator.SMALLERDOT, loc(label.getOffset())));
|
//constraintsSet.addUndConstraint(new Pair(label.getPattern().getType(), switchStmt.getSwitch().getType(), PairOperator.SMALLERDOT, loc(label.getOffset())));
|
||||||
} else if (label.getPattern() instanceof FormalParameter) {
|
} else if (label.getPattern() instanceof FormalParameter) {
|
||||||
constraintsSet.addUndConstraint(new Pair(label.getPattern().getType(), switchStmt.getSwitch().getType(), PairOperator.SMALLERDOT, loc(label.getOffset())));
|
constraintsSet.addUndConstraint(new Pair(label.getPattern().getType(), switchStmt.getSwitch().getType(), PairOperator.SMALLERDOT, loc(label.getOffset())));
|
||||||
@ -870,13 +869,22 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
|
|
||||||
var test = "";
|
var test = "";
|
||||||
|
|
||||||
|
var constructors = interestingClasses.get(0).getConstructors();
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getSubPattern().size(); i++) {
|
for (int i = 0; i < pattern.getSubPattern().size(); i++) {
|
||||||
var supPattern = pattern.getSubPattern().get(i);
|
var supPattern = pattern.getSubPattern().get(i);
|
||||||
for (int j = 0; j < interestingClasses.size(); j++) {
|
for (int j = 0; j < interestingClasses.size(); j++) {
|
||||||
constraintsSet.addUndConstraint(new Pair(supPattern.getType(), interestingClasses.get(j).getFieldDecl().get(i).getType(), PairOperator.SMALLERDOT, loc(switchStmt.getOffset())));
|
var clazz = interestingClasses.get(j);
|
||||||
}
|
for (int k = 0; k < clazz.getConstructors().size(); k++) {
|
||||||
|
var constructor = clazz.getConstructors().get(k);
|
||||||
|
//Erster Constraint wahrscheinlich unnötig.
|
||||||
|
constraintsSet.addUndConstraint(new Pair( clazz.getFieldDecl().get(i).getType(), constructor.getParameterList().getParameterAt(i).getType(), PairOperator.SMALLERDOT, loc(constructor.getParameterList().getParameterAt(i).getOffset())));
|
||||||
|
constraintsSet.addUndConstraint(new Pair(supPattern.getType(), constructor.getParameterList().getParameterAt(i).getType(), PairOperator.SMALLERDOT, loc(constructor.getParameterList().getParameterAt(i).getOffset())));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -687,10 +687,10 @@ public class TestComplete {
|
|||||||
|
|
||||||
var record = classFiles.get("Rec");
|
var record = classFiles.get("Rec");
|
||||||
var ctor = record.getDeclaredConstructor(Object.class, Object.class);
|
var ctor = record.getDeclaredConstructor(Object.class, Object.class);
|
||||||
var r1 = ctor.newInstance(1, 1);
|
var r1 = ctor.newInstance("asd", "asb");
|
||||||
|
|
||||||
|
|
||||||
assertEquals(swtch.invoke(instance, r1), 1);
|
assertEquals(swtch.invoke(instance, r1), "asd");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Not implemented")
|
@Ignore("Not implemented")
|
||||||
|
Loading…
Reference in New Issue
Block a user