public sealed interface Statement permits Print
{
void run();
}
public record Print(Expression expression) implements Statement
{
public void run()
{
System.out.print(ExpressionEval.evaluate(expression));
}
}
private Statement parsePrint()
{
if (Objects.requireNonNull(peek()).type() == TokenType.NUMBER)
return new Print(giveExpression()); // error
}
Expression giveExpression()
{
return parseExpression();
}
#Print incompatible with Statement
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
no
it says Incompatible types. Found: 'geletin.jelly.statements.Print', required: 'geletin.jelly.Statement'
private Statement parsePrint()
{
if (Objects.requireNonNull(peek()).type() == TokenType.NUMBER) {
return new Print(giveExpression()); // error
}
else {
throw new RuntimeException();
}
}
Statement only lives in statements package
do you have two Statement classes in your project?
geletin.jelly.Statement because clearly the compiler thinks there is one here