diff --git a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/evaluator/fold/InlineVariableRead.java b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/evaluator/fold/InlineVariableRead.java index fc608681..f21de6da 100644 --- a/autograder-core/src/main/java/de/firemage/autograder/core/integrated/evaluator/fold/InlineVariableRead.java +++ b/autograder-core/src/main/java/de/firemage/autograder/core/integrated/evaluator/fold/InlineVariableRead.java @@ -1,6 +1,7 @@ package de.firemage.autograder.core.integrated.evaluator.fold; import de.firemage.autograder.core.integrated.SpoonUtil; +import de.firemage.autograder.core.integrated.UsesFinder; import spoon.reflect.code.CtExpression; import spoon.reflect.code.CtLiteral; import spoon.reflect.code.CtLocalVariable; @@ -30,7 +31,7 @@ public static Fold create(boolean ignoreLocalVariables) { @Override @SuppressWarnings("unchecked") public CtExpression foldCtVariableRead(CtVariableRead ctVariableRead) { - CtVariable ctVariable = ctVariableRead.getVariable().getDeclaration(); + CtVariable ctVariable = (CtVariable) UsesFinder.getDeclaredVariable(ctVariableRead); if (ctVariable == null || this.ignoreLocalVariables && ctVariable instanceof CtLocalVariable) { return ctVariableRead;