diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 3f11424b..30323d6e 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -35,19 +35,19 @@ public class FamilyOfGeneratedGenerics { cs_cl.add(cons); } } - boolean addedToConstraintsList = false; - do { - addedToConstraintsList = false; - List classConstraints2 = new ArrayList<>(); - classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher + // if sth new is added to cs_cl, then do same step again + boolean addedToConstraintsListForCC2 = false; + do { + addedToConstraintsListForCC2 = false; + List classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher for (ClassConstraint cons: classConstraints2) { if (!checkForDuplicates(cons, cs_cl)) { cs_cl.add(cons); - addedToConstraintsList = true; + addedToConstraintsListForCC2 = true; } } - }while(addedToConstraintsList); + } while (addedToConstraintsListForCC2); List classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs); for (ClassConstraint cons: classConstraints3) { @@ -59,7 +59,6 @@ public class FamilyOfGeneratedGenerics { } public static List getMethodConstraints(List cs, List cs_cl, HashMap> posOfTphs) { - //TODO: Regeln List cs_m = new ArrayList<>(); List methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs); for (MethodConstraint cons: methodConstraints1) { @@ -67,18 +66,32 @@ public class FamilyOfGeneratedGenerics { cs_m.add(cons); } } - List methodConstraints2 = firstTransitiveSubtypeForMethodTypes(cs, cs_m); - for (MethodConstraint cons: methodConstraints2) { - if (!checkForDuplicates(cons, cs_m)) { - cs_m.add(cons); + + // if sth new is added to cs_cl, then do same step again + boolean addedToConstraintsListForMC2 = false; + do { + addedToConstraintsListForMC2 = false; + List methodConstraints2 = firstTransitiveSubtypeForMethodTypes(cs, cs_m); + for (MethodConstraint cons : methodConstraints2) { + if (!checkForDuplicates(cons, cs_m)) { + cs_m.add(cons); + addedToConstraintsListForMC2 = true; + } } - } - List methodConstraints3 = secondTransitiveSubtypeForMethodTypes(cs, cs_cl, cs_m); - for (MethodConstraint cons: methodConstraints3) { - if (!checkForDuplicates(cons, cs_m)) { - cs_m.add(cons); + } while (addedToConstraintsListForMC2); + + // if sth new is added to cs_cl, then do same step again + boolean addedToConstraintsListForMC3 = false; + do { + addedToConstraintsListForMC3 = false; + List methodConstraints3 = secondTransitiveSubtypeForMethodTypes(cs, cs_cl, cs_m); + for (MethodConstraint cons : methodConstraints3) { + if (!checkForDuplicates(cons, cs_m)) { + cs_m.add(cons); + addedToConstraintsListForMC3 = true; + } } - } + } while (addedToConstraintsListForMC3); List methodConstraints4 = hasNoSupertypeForMethodTypes(cs, posOfTphs); for (MethodConstraint cons: methodConstraints4) { if (!checkForDuplicates(cons, cs_m)) {