diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 097185e00..8b8b28522 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -816,28 +816,15 @@ public class FamilyOfGeneratedGenerics { public static List methodTypesWithoutClassTypesNEW(String tphToCompute, List cs_m, HashMap>> posOfTphs) { List tempMC = new ArrayList<>(cs_m); - if(tphToCompute==null || tphToCompute.isEmpty()) { - 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) { - if(tphCons.getLeft() == tphToCompute) { - String newRightTPH = tphCons.getRight(); - tempMC.remove(tphCons); - methodTypesWithoutClassTypesNEW(newRightTPH,tempMC,posOfTphs); - } + List tempMC2 = new ArrayList<>(cs_m); + for(TPHConstraint tphCons: tempMC) { + if(tphCons.getLeft() == tphToCompute) { + String newRightTPH = tphCons.getRight(); + tempMC2.remove(tphCons); + tempMC2 = methodTypesWithoutClassTypesNEW(newRightTPH,tempMC2,posOfTphs); } } - return tempMC; + return tempMC2; } @@ -888,7 +875,13 @@ public class FamilyOfGeneratedGenerics { } // 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); } diff --git a/src/test/java/insertGenerics/TestTwoArgs.java b/src/test/java/insertGenerics/TestTwoArgs.java index 8016a0396..faa405e2a 100644 --- a/src/test/java/insertGenerics/TestTwoArgs.java +++ b/src/test/java/insertGenerics/TestTwoArgs.java @@ -65,11 +65,13 @@ public class TestTwoArgs { Set lmc; lmc = new HashSet<>(); 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); lmc = new HashSet<>(); lmc.add(new MethodConstraint("AL", "AF", Relation.EXTENDS)); lmc.add(new MethodConstraint("Z", "P", 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); lmc = new HashSet<>(); lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS));