From 877e5ed38af0a9aa9de612736f0971fb938a97ca Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Wed, 27 Mar 2024 14:52:15 +0100 Subject: [PATCH] Reversing alone would disturb the parameters (#298) --- .../de/dhbwstuttgart/typeinference/unify/RuleSet.java | 1 - .../typeinference/unify/model/FiniteClosure.java | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index 036dba9c..e318f737 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -906,7 +906,6 @@ public class RuleSet implements IRuleSet{ var fiArgs = fc.getFunctionalInterfaceTypeArguments(refType); var retType = fiArgs.getFirst(); - System.out.println(lhsType.getName()); var lhsArgs = fc.getFunctionalInterfaceTypeArguments(lhsType); var lhsRet = lhsArgs.getFirst(); 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 99caa0b3..9c8301e0 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -4,6 +4,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.lang.reflect.Modifier; +import java.sql.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -613,7 +614,14 @@ implements IFiniteClosure { @Override public List getFunctionalInterfaceTypeArguments(UnifyType t) { - if (t instanceof FunNType) return Arrays.asList(t.getTypeParams().get()).reversed(); + if (t instanceof FunNType) { + var ret = new ArrayList(); + if (t.getTypeParams().size() > 0) { + ret.add(t.getTypeParams().get(t.getTypeParams().size() - 1)); + ret.addAll(Arrays.asList(t.getTypeParams().get()).subList(0, t.getTypeParams().size() - 1)); + } + return ret; + } var clazz = compiler.getClass(new JavaClassName(t.getName())); var intfMethod = clazz.getMethods().stream().filter(m -> Modifier.isAbstract(m.modifier)).findFirst().orElseThrow();