From a9f69ead5c6ec929e13783ec4cfe27aa42618f25 Mon Sep 17 00:00:00 2001 From: Victorious3 Date: Tue, 24 Jan 2023 15:11:31 +0100 Subject: [PATCH] Use signature in methodcall --- .../target/generate/StatementToTargetExpression.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java b/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java index 2f809f41..b6a8f12f 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) {