modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java

modified:   src/test/java/insertGenerics/TestTwoArgs.java
This commit is contained in:
AluAli 2021-03-26 19:58:38 +01:00
parent da2a17c794
commit 32e9ce92a6
2 changed files with 16 additions and 21 deletions

View File

@ -816,28 +816,15 @@ public class FamilyOfGeneratedGenerics {
public static List<MethodConstraint> methodTypesWithoutClassTypesNEW(String tphToCompute, List<MethodConstraint> cs_m, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) { public static List<MethodConstraint> methodTypesWithoutClassTypesNEW(String tphToCompute, List<MethodConstraint> cs_m, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) {
List<MethodConstraint> tempMC = new ArrayList<>(cs_m); List<MethodConstraint> tempMC = new ArrayList<>(cs_m);
if(tphToCompute==null || tphToCompute.isEmpty()) { List<MethodConstraint> tempMC2 = new ArrayList<>(cs_m);
for(TPHConstraint tphCons: tempMC) {
for(String tph: posOfTphs.keySet()){
for(PairTphMethod p: posOfTphs.get(tph)) {
if(p.fst == PositionFinder.Position.FIELD && tphCons.getLeft() == tph) {
String rightTPH = tphCons.getRight();
tempMC.remove(tphCons);
methodTypesWithoutClassTypesNEW(rightTPH,tempMC,posOfTphs);
}
}
}
}
} else {
for(TPHConstraint tphCons: tempMC) { for(TPHConstraint tphCons: tempMC) {
if(tphCons.getLeft() == tphToCompute) { if(tphCons.getLeft() == tphToCompute) {
String newRightTPH = tphCons.getRight(); String newRightTPH = tphCons.getRight();
tempMC.remove(tphCons); tempMC2.remove(tphCons);
methodTypesWithoutClassTypesNEW(newRightTPH,tempMC,posOfTphs); tempMC2 = methodTypesWithoutClassTypesNEW(newRightTPH,tempMC2,posOfTphs);
} }
} }
} return tempMC2;
return tempMC;
} }
@ -888,7 +875,13 @@ public class FamilyOfGeneratedGenerics {
} }
// mcWithoutCc = methodTypesWithoutClassTypes(cs_cl, listToAdd); // mcWithoutCc = methodTypesWithoutClassTypes(cs_cl, listToAdd);
mcWithoutCc = methodTypesWithoutClassTypesNEW(null, listToAdd, posOfTphs); for(String tph: posOfTphs.keySet()) {
for (PairTphMethod p : posOfTphs.get(tph)) {
if(p.fst == PositionFinder.Position.FIELD) {
mcWithoutCc = methodTypesWithoutClassTypesNEW(tph, listToAdd, posOfTphs);
}
}
}
tempMethodConstraintsWithPosition.put(currentMethod, mcWithoutCc); tempMethodConstraintsWithPosition.put(currentMethod, mcWithoutCc);
} }

View File

@ -65,11 +65,13 @@ public class TestTwoArgs {
Set<MethodConstraint> lmc; Set<MethodConstraint> lmc;
lmc = new HashSet<>(); lmc = new HashSet<>();
lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS)); lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS));
lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ALid(TPH P)", lmc); methodConstraintsWithPositionTest.put("TPH ALid(TPH P)", lmc);
lmc = new HashSet<>(); lmc = new HashSet<>();
lmc.add(new MethodConstraint("AL", "AF", Relation.EXTENDS)); lmc.add(new MethodConstraint("AL", "AF", Relation.EXTENDS));
lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS)); lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS));
lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS)); lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS));
lmc.add(new MethodConstraint("AF", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH AFm(TPH AFTPH Z)", lmc); methodConstraintsWithPositionTest.put("TPH AFm(TPH AFTPH Z)", lmc);
lmc = new HashSet<>(); lmc = new HashSet<>();
lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS)); lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS));