From 9bf273ac1a2c6015c25f798c8788d4c460484dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Sun, 4 Nov 2018 11:33:32 +0100 Subject: [PATCH] modified: ../../src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java Unterscheidung zwischen FUNN-Receiver und anderem Receiver wieder geloescht (war nur auskmmentiert) modified: ../../src/de/dhbwstuttgart/typeinference/unify/RuleSet.java Fehler in der Reduce-FUNN-Rege beseitigt --- .../typeinference/typeAlgo/TYPEStmt.java | 8 +------- .../typeinference/unify/RuleSet.java | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index cad3a62f..330127af 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -520,14 +520,8 @@ public class TYPEStmt implements StatementVisitor{ */ RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver); - /* if (retType instanceof FunN) { - methodConstraint.add(new Pair(forMethod.receiver.getType(), retType, - PairOperator.EQUALSDOT)); - } - else {//RefType */ - methodConstraint.add(new Pair(forMethod.receiver.getType(), retType, + methodConstraint.add(new Pair(forMethod.receiver.getType(), retType, PairOperator.SMALLERDOT)); - //} methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT)); methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver)); diff --git a/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java index e438d500..d4e6b551 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -782,10 +782,17 @@ public class RuleSet implements IRuleSet{ return Optional.empty(); Set result = new HashSet(); - - result.add(new UnifyPair(funNLhsType.getTypeParams().get(funNLhsType.getTypeParams().size()-1), funNRhsType.getTypeParams().get(funNRhsType.getTypeParams().size()-1), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair())); - for(int i = 0; i < funNLhsType.getTypeParams().size()-1; i++) { - result.add(new UnifyPair(funNRhsType.getTypeParams().get(i), funNLhsType.getTypeParams().get(i), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair())); + if (pair.getPairOp() == PairOperator.SMALLERDOT) { + result.add(new UnifyPair(funNLhsType.getTypeParams().get(funNLhsType.getTypeParams().size()-1), funNRhsType.getTypeParams().get(funNRhsType.getTypeParams().size()-1), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair())); + for(int i = 0; i < funNLhsType.getTypeParams().size()-1; i++) { + result.add(new UnifyPair(funNRhsType.getTypeParams().get(i), funNLhsType.getTypeParams().get(i), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair())); + } + } + else {// pair.getPairOp() == PairOperator.EQUALDOT + result.add(new UnifyPair(funNLhsType.getTypeParams().get(funNLhsType.getTypeParams().size()-1), funNRhsType.getTypeParams().get(funNRhsType.getTypeParams().size()-1), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair())); + for(int i = 0; i < funNLhsType.getTypeParams().size()-1; i++) { + result.add(new UnifyPair(funNRhsType.getTypeParams().get(i), funNLhsType.getTypeParams().get(i), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair())); + } } result.stream().forEach(x -> { UnifyType l = x.getLhsType(); if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); } @@ -798,7 +805,7 @@ public class RuleSet implements IRuleSet{ logFile.flush(); } catch (IOException e) { - System.out.println("lofFile-Error"); + System.out.println("logFile-Error"); } return Optional.of(result); }