diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index c8437abd..bd054a7c 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -576,7 +576,7 @@ public class TYPEStmt implements StatementVisitor{ methodConstraint.add(new Pair(forMethod.receiver.getType(), retType, PairOperator.SMALLERDOT)); - //Fuer Bytecodegenerierung + //Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt methodConstraint.add(new Pair(forMethod.receiverType, retType, PairOperator.EQUALSDOT)); @@ -595,7 +595,7 @@ public class TYPEStmt implements StatementVisitor{ RefTypeOrTPHOrWildcardOrGeneric assType = assumption.getArgTypes(resolver).get(i); ret.add(new Pair(argType, assType, PairOperator.SMALLERDOT)); - //Fuer Bytecodegenerierung + //Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ret.add(new Pair(foMethod.argTypes.get(i), assType, PairOperator.EQUALSDOT)); } return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java index 736186d5..c342269b 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java @@ -293,24 +293,25 @@ public class OrderingUnifyPair extends Ordering> { } else { if (leftlewc.size() > 0) { Set subst; - if (leftlewc.iterator().next().getLhsType() instanceof PlaceholderType) { - subst = leftlewc.stream().map(x -> new UnifyPair(x.getLhsType(), x.getRhsType(), PairOperator.EQUALSDOT)).collect(Collectors.toCollection(HashSet::new)); - } - else { - subst = leftlewc.stream().map(x -> new UnifyPair(x.getRhsType(), x.getLhsType(), PairOperator.EQUALSDOT)).collect(Collectors.toCollection(HashSet::new)); - } + subst = leftlewc.stream().map(x -> { + if (x.getLhsType() instanceof PlaceholderType) { + return new UnifyPair(x.getLhsType(), x.getRhsType(), PairOperator.EQUALSDOT); + } + else { + return new UnifyPair(x.getRhsType(), x.getLhsType(), PairOperator.EQUALSDOT); + }}).collect(Collectors.toCollection(HashSet::new)); Unifier uni = new Unifier(); - subst.stream().forEach(x -> uni.add((PlaceholderType) x.getLhsType(), x.getRhsType())); lseq = uni.apply(lseq); } else { Set subst; - if (rightlewc.iterator().next().getLhsType() instanceof PlaceholderType) { - subst = rightlewc.stream().map(x -> new UnifyPair(x.getLhsType(), x.getRhsType(), PairOperator.EQUALSDOT)).collect(Collectors.toCollection(HashSet::new)); - } - else { - subst = rightlewc.stream().map(x -> new UnifyPair(x.getRhsType(), x.getLhsType(), PairOperator.EQUALSDOT)).collect(Collectors.toCollection(HashSet::new)); - } + subst = rightlewc.stream().map(x -> { + if (x.getLhsType() instanceof PlaceholderType) { + return new UnifyPair(x.getLhsType(), x.getRhsType(), PairOperator.EQUALSDOT); + } + else { + return new UnifyPair(x.getRhsType(), x.getLhsType(), PairOperator.EQUALSDOT); + }}).collect(Collectors.toCollection(HashSet::new)); Unifier uni = new Unifier(); subst.stream().forEach(x -> uni.add((PlaceholderType) x.getLhsType(), x.getRhsType())); rseq = uni.apply(rseq);