diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java index 78f7360f..3e995607 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java @@ -22,6 +22,8 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType; public class Match implements IMatch { @Override + //A =. A ==> True + //A =. A ==> False public Optional match(ArrayList termsList) { // Start with the identity unifier. Substitutions will be added later. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index a28f45df..75b070de 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -1309,8 +1309,8 @@ public class TypeUnifyTask extends RecursiveTask>> { if (eq2sAsList.isEmpty() && first) {//Alle eq2s sind empty und alle oderConstraints mit Variance != 0 sind bearbeitet if (!oderConstraintsOutput.isEmpty()) { Set> ret = oderConstraintsOutput.remove(0); - if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M")) - System.out.println("M"); + //if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M")) + // System.out.println("M"); //Set retFlat = new HashSet<>(); //ret.stream().forEach(x -> retFlat.addAll(x)); ret.stream().forEach(x -> x.stream().forEach(y -> y.addSubstitutions(x))); @@ -1476,9 +1476,14 @@ public class TypeUnifyTask extends RecursiveTask>> { allGen = false; break; } - + //if (thetaPrime.getName().equals("java.util.Vector") //Fuer Bug 127 + // && thetaPrime instanceof ReferenceType + // && ((ReferenceType)thetaPrime).getTypeParams().iterator().next().getName().equals("java.util.Vector") + // && ((ReferenceType)((ReferenceType)thetaPrime).getTypeParams().iterator().next()).getTypeParams().iterator().next().getName().equals("java.lang.Integer")) { + // System.out.println(""); + //} Set cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector, java.util.Vector>, ????java.util.Vector???] - + //Set cs = fc.getAllTypesByMatch(thetaPrime); //PL 2019-01-02 geaendet wegen Bug 127//SO GEHT ES NICHT //PL 18-02-06 entfernt, kommt durch unify wieder rein @@ -1522,19 +1527,21 @@ public class TypeUnifyTask extends RecursiveTask>> { } for(UnifyType tqp : thetaQPrimes) { + Collection tphs = tqp.getInvolvedPlaceholderTypes(); Optional opt = stdUnify.unify(tqp, thetaPrime); if (!opt.isPresent()) { continue; } - Unifier unifier = opt.get(); unifier.swapPlaceholderSubstitutions(thetaPrime.getTypeParams()); Set substitutionSet = new HashSet<>(); for (Entry sigma : unifier) { - substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT, + if (!tphs.contains(sigma.getKey())) {//eingefuegt PL 2019-02-02 Bug 127 + substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT, //TODO: nochmals ueberlegen ob hier pair.getSubstitution() korrekt ist, oder ob leere Menge hin müsste //alle folgenden New UnifyPair ebenfalls ueberpruefen PL 2018-04-19 pair.getSubstitution(), pair)); + } } //List freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben for (UnifyType tq : thetaQs) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java index 4aa769e5..2c2cbd5d 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -487,7 +487,7 @@ implements IFiniteClosure { result.add(type); return result; } - + @Override public Set getAllTypesByName(String typeName) { if(!strInheritanceGraph.containsKey(typeName)) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index 01209998..8a357bbb 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -157,7 +157,7 @@ public final class PlaceholderType extends UnifyType{ @Override - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.add(this); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java index bb7bc1c6..298f87e7 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java @@ -97,7 +97,7 @@ public abstract class UnifyType { return typeName + params; } - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.addAll(typeParams.getInvolvedPlaceholderTypes()); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java index 81999492..ea70139f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java @@ -64,7 +64,7 @@ public abstract class WildcardType extends UnifyType { @Override - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.addAll(wildcardedType.getInvolvedPlaceholderTypes()); return ret; diff --git a/src/test/resources/bytecode/javFiles/MatrixOP.jav b/src/test/resources/bytecode/javFiles/MatrixOP.jav index 828a270b..c78c42c7 100644 --- a/src/test/resources/bytecode/javFiles/MatrixOP.jav +++ b/src/test/resources/bytecode/javFiles/MatrixOP.jav @@ -1,6 +1,6 @@ import java.util.Vector; import java.lang.Integer; -//import java.lang.Byte; +import java.lang.Byte; import java.lang.Boolean; public class MatrixOP extends Vector> { diff --git a/src/test/resources/bytecode/javFiles/Merge.jav b/src/test/resources/bytecode/javFiles/Merge.jav index 9240146e..ad5e103e 100644 --- a/src/test/resources/bytecode/javFiles/Merge.jav +++ b/src/test/resources/bytecode/javFiles/Merge.jav @@ -1,8 +1,8 @@ import java.util.List; import java.lang.Integer; -import java.util.Collection; +//import java.util.Collection; -class Merge { +class Merge { merge(a, b) { a.addAll(b);