diff --git a/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java b/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java index 2f809f41f..b6a8f12f7 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java @@ -9,10 +9,7 @@ import de.dhbwstuttgart.syntaxtree.statement.*; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.target.tree.MethodParameter; import de.dhbwstuttgart.target.tree.expression.*; -import de.dhbwstuttgart.target.tree.type.TargetFunNType; -import de.dhbwstuttgart.target.tree.type.TargetRefType; -import de.dhbwstuttgart.target.tree.type.TargetSpecializedType; -import de.dhbwstuttgart.target.tree.type.TargetType; +import de.dhbwstuttgart.target.tree.type.*; import java.lang.reflect.Method; import java.util.*; @@ -172,7 +169,7 @@ public class StatementToTargetExpression implements StatementVisitor { } static boolean convertsTo(TargetType from, TargetType to) { - if (to.equals(TargetType.Object)) return true; // TODO Consider type coercion and suptyping + if (to.equals(TargetType.Object)) return true; // TODO Consider type coercion and subtyping return to.equals(from); } @@ -213,9 +210,10 @@ public class StatementToTargetExpression implements StatementVisitor { public void visit(MethodCall methodCall) { var receiverType = converter.convert(methodCall.receiver.getType()); var isFunNType = receiverType instanceof TargetFunNType; - var returnType = isFunNType ? TargetType.Object : converter.convert(methodCall.getType()); + var returnType = isFunNType ? TargetType.Object : converter.convert(methodCall.signature.get(methodCall.signature.size() - 1)); var receiverName = new JavaClassName(converter.convert(methodCall.receiver.getType()).name()); - var argList = methodCall.arglist.getArguments().stream().map(expr -> converter.convert(expr.getType())).toList(); + var argList = methodCall.signature.stream().map(converter::convert).toList(); + argList = argList.subList(0, argList.size() - 1); Method foundMethod = null; if (methodCall.receiver instanceof ExpressionReceiver expressionReceiver && expressionReceiver.expr instanceof This) {