From b402857713e71531df90f29aa81fd06ba7a6e069 Mon Sep 17 00:00:00 2001 From: StefanZ3 Date: Tue, 25 Jun 2024 17:09:16 +0200 Subject: [PATCH] fix methodCall --- src/main/java/astGenerator/ASTGenerator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/astGenerator/ASTGenerator.java b/src/main/java/astGenerator/ASTGenerator.java index c4bb951..3d7d34e 100644 --- a/src/main/java/astGenerator/ASTGenerator.java +++ b/src/main/java/astGenerator/ASTGenerator.java @@ -206,8 +206,12 @@ public class ASTGenerator extends DecafBaseVisitor { for(DecafParser.ReceivingMethodContext receivingMethod: ctx.receivingMethod()) { receivingMethods.add((ReceivingMethod) visit(receivingMethod)); } - Receiver receiver = (Receiver) visit(ctx.receiver()); - return new MethodCallStatementExpression(methodName, receiver, receivingMethods, arguments); + if (ctx.receiver() != null) { + Receiver receiver = (Receiver) visit(ctx.receiver()); + return new MethodCallStatementExpression(methodName, receiver, receivingMethods, arguments); + } else { + return new MethodCallStatementExpression(methodName, null, receivingMethods, arguments); + } } @Override