diff --git a/resources/bytecode/javFiles/Bug298.jav b/resources/bytecode/javFiles/Bug298.jav index 296ee028..42ff96a3 100644 --- a/resources/bytecode/javFiles/Bug298.jav +++ b/resources/bytecode/javFiles/Bug298.jav @@ -2,6 +2,7 @@ import java.util.List; import java.util.ArrayList; import java.lang.Integer; import java.lang.System; +import java.lang.Boolean; import java.io.PrintStream; import java.util.stream.Stream; import java.util.function.Function; @@ -10,5 +11,7 @@ public class Bug298 { public void m() { List list = new ArrayList<>(); list.stream().map(x -> 2 * x); + + Function filter = x -> true; } } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index 262f764e..e318f737 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -14,6 +14,7 @@ import java.util.stream.Collectors; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.exceptions.DebugException; +import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; @@ -905,7 +906,8 @@ public class RuleSet implements IRuleSet{ var fiArgs = fc.getFunctionalInterfaceTypeArguments(refType); var retType = fiArgs.getFirst(); - var lhsRet = lhsType.getTypeParams().get(0); + var lhsArgs = fc.getFunctionalInterfaceTypeArguments(lhsType); + var lhsRet = lhsArgs.getFirst(); Set result = new HashSet<>(); if (retType instanceof ExtendsType) { @@ -917,7 +919,7 @@ public class RuleSet implements IRuleSet{ } for (var i = 1; i < fiArgs.size(); i++) { - var lh = lhsType.getTypeParams().get(i); + var lh = lhsArgs.get(i); var rh = fiArgs.get(i); if (rh instanceof SuperType) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java index d87aedab..707d320f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java @@ -75,7 +75,7 @@ public interface IFiniteClosure { public Set getAllTypesByName(String typeName); public boolean isFunctionalInterface(ReferenceType t); - public List getFunctionalInterfaceTypeArguments(ReferenceType t); + public List getFunctionalInterfaceTypeArguments(UnifyType t); public int compare(UnifyType rhsType, UnifyType rhsType2, PairOperator pairop); } 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 81eac231..0dd832ac 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -612,7 +612,7 @@ implements IFiniteClosure { } @Override - public List getFunctionalInterfaceTypeArguments(ReferenceType t) { + public List getFunctionalInterfaceTypeArguments(UnifyType t) { var clazz = compiler.getClass(new JavaClassName(t.getName())); var intfMethod = clazz.getMethods().stream().filter(m -> Modifier.isAbstract(m.modifier)).findFirst().orElseThrow(); @@ -630,6 +630,7 @@ implements IFiniteClosure { i += 1; } + System.out.println(args); return args; }