Fix #298 maybe?
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 2m42s

This commit is contained in:
Daniel Holle 2024-03-26 17:31:48 +01:00
parent bc61fc2e1d
commit 8fdfbf875b
4 changed files with 10 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.lang.Integer; import java.lang.Integer;
import java.lang.System; import java.lang.System;
import java.lang.Boolean;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.function.Function; import java.util.function.Function;
@ -10,5 +11,7 @@ public class Bug298 {
public void m() { public void m() {
List<Integer> list = new ArrayList<>(); List<Integer> list = new ArrayList<>();
list.stream().map(x -> 2 * x); list.stream().map(x -> 2 * x);
Function<Integer, Boolean> filter = x -> true;
} }
} }

View File

@ -14,6 +14,7 @@ import java.util.stream.Collectors;
import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.exceptions.DebugException; import de.dhbwstuttgart.exceptions.DebugException;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType; import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
@ -905,7 +906,8 @@ public class RuleSet implements IRuleSet{
var fiArgs = fc.getFunctionalInterfaceTypeArguments(refType); var fiArgs = fc.getFunctionalInterfaceTypeArguments(refType);
var retType = fiArgs.getFirst(); var retType = fiArgs.getFirst();
var lhsRet = lhsType.getTypeParams().get(0); var lhsArgs = fc.getFunctionalInterfaceTypeArguments(lhsType);
var lhsRet = lhsArgs.getFirst();
Set<UnifyPair> result = new HashSet<>(); Set<UnifyPair> result = new HashSet<>();
if (retType instanceof ExtendsType) { if (retType instanceof ExtendsType) {
@ -917,7 +919,7 @@ public class RuleSet implements IRuleSet{
} }
for (var i = 1; i < fiArgs.size(); i++) { for (var i = 1; i < fiArgs.size(); i++) {
var lh = lhsType.getTypeParams().get(i); var lh = lhsArgs.get(i);
var rh = fiArgs.get(i); var rh = fiArgs.get(i);
if (rh instanceof SuperType) { if (rh instanceof SuperType) {

View File

@ -75,7 +75,7 @@ public interface IFiniteClosure {
public Set<UnifyType> getAllTypesByName(String typeName); public Set<UnifyType> getAllTypesByName(String typeName);
public boolean isFunctionalInterface(ReferenceType t); public boolean isFunctionalInterface(ReferenceType t);
public List<UnifyType> getFunctionalInterfaceTypeArguments(ReferenceType t); public List<UnifyType> getFunctionalInterfaceTypeArguments(UnifyType t);
public int compare(UnifyType rhsType, UnifyType rhsType2, PairOperator pairop); public int compare(UnifyType rhsType, UnifyType rhsType2, PairOperator pairop);
} }

View File

@ -612,7 +612,7 @@ implements IFiniteClosure {
} }
@Override @Override
public List<UnifyType> getFunctionalInterfaceTypeArguments(ReferenceType t) { public List<UnifyType> getFunctionalInterfaceTypeArguments(UnifyType t) {
var clazz = compiler.getClass(new JavaClassName(t.getName())); var clazz = compiler.getClass(new JavaClassName(t.getName()));
var intfMethod = clazz.getMethods().stream().filter(m -> Modifier.isAbstract(m.modifier)).findFirst().orElseThrow(); var intfMethod = clazz.getMethods().stream().filter(m -> Modifier.isAbstract(m.modifier)).findFirst().orElseThrow();
@ -630,6 +630,7 @@ implements IFiniteClosure {
i += 1; i += 1;
} }
System.out.println(args);
return args; return args;
} }