From 32e9ce92a645f039f0cd66fd4f507b04d1d4bb61 Mon Sep 17 00:00:00 2001 From: AluAli Date: Fri, 26 Mar 2021 19:58:38 +0100 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java modified: src/test/java/insertGenerics/TestTwoArgs.java --- .../FamilyOfGeneratedGenerics.java | 35 ++++++++----------- src/test/java/insertGenerics/TestTwoArgs.java | 2 ++ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 097185e0..8b8b2852 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 8016a039..faa405e2 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));