From 97ab66122ea4d3411b384b87b92087c86742476a Mon Sep 17 00:00:00 2001 From: Jochen Seyfried Date: Wed, 3 Jul 2024 11:56:47 +0200 Subject: [PATCH] Fixed methodCalls with no receiver --- .../MethodCallStatementExpression.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java b/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java index 1107172..e36e926 100644 --- a/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java +++ b/src/main/java/abstractSyntaxTree/StatementExpression/MethodCallStatementExpression.java @@ -121,7 +121,9 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr throw new ExecutionControl.NotImplementedException("Receiver type not supported."); } } else { - throw new ExecutionControl.NotImplementedException("Receiver is null."); + mv.visitVarInsn(Opcodes.ALOAD, 0); + owner = thisClass; + } String returnOfPreviousMethod = null; // Invoke the method for each receiving method in the chain @@ -185,12 +187,17 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr } descriptor.append(")"); + String classToSearchMethodIn; //Return Type - String classToSearchMethodIn = localVars.get(receiver.identifier); - if (classToSearchMethodIn == null) { - classToSearchMethodIn = returnOfPreviousMethod; - } - if (classToSearchMethodIn == null) { + if (receiver != null) { + classToSearchMethodIn = localVars.get(receiver.identifier); + if (classToSearchMethodIn == null) { + classToSearchMethodIn = returnOfPreviousMethod; + } + if (classToSearchMethodIn == null) { + classToSearchMethodIn = thisClass; + } + } else { classToSearchMethodIn = thisClass; }