From dfd91b5f8b7fca1cb5f302eec4b0ba3330271c9b Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Fri, 1 Sep 2023 17:18:51 +0200 Subject: [PATCH] TESTEN OB DAS SINN MACHT modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: src/test/java/AllgemeinTest.java --- .../typeinference/unify/TypeUnifyTask.java | 15 +++++++++++++++ src/test/java/AllgemeinTest.java | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index bc72ce39..f9c2d182 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -371,6 +371,21 @@ public class TypeUnifyTask extends RecursiveTask>> { do { eq0Prime = eqSubst.get(); eq0 = applyTypeUnificationRules(eq0Prime, fc); + Set occurcheck = new HashSet<>(eq0); + occurcheck.removeAll(eq0Prime); + ocurrPairs = occurcheck.stream().filter(x -> { + UnifyType lhs, rhs; + return (lhs = x.getLhsType()) instanceof PlaceholderType + && !((rhs = x.getRhsType()) instanceof PlaceholderType) + && rhs.getTypeParams().occurs((PlaceholderType)lhs);}) + .map(x -> { x.setUndefinedPair(); return x;}) + .collect(Collectors.toCollection(HashSet::new)); + writeLog("ocurrPairs: " + ocurrPairs); + if (ocurrPairs.size() > 0) { + Set> ret = new HashSet<>(); + ret.add(ocurrPairs); + return ret; + } eqSubst = rules.subst(eq0, oderConstraints); } while (eqSubst.isPresent()); diff --git a/src/test/java/AllgemeinTest.java b/src/test/java/AllgemeinTest.java index 60ef6659..21c036b4 100644 --- a/src/test/java/AllgemeinTest.java +++ b/src/test/java/AllgemeinTest.java @@ -41,6 +41,7 @@ public class AllgemeinTest { //String className = "Var"; //String className = "Put"; //String className = "Twice"; + //String className = "Twice2"; //String className = "TestSubTypless"; //String className = "addList"; //String className = "M"; @@ -56,7 +57,8 @@ public class AllgemeinTest { //String className = "UseWildcardPair"; //String className = "Assign"; //String className = "StreamTest"; - String className = "Iteration"; + //String className = "Iteration"; + String className = "Cycle"; //PL 2019-10-24: genutzt fuer unterschiedliche Tests path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav"; //path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";