janino-compiler / janino

Janino is a super-small, super-fast Java™ compiler.
http://janino-compiler.github.io/janino
Other
1.21k stars 205 forks source link

Evaluate method is ambiguous #204

Closed caithesi closed 7 months ago

caithesi commented 1 year ago

I am using java 17, janino version 3.1.9 When i try to call evaluate method with at least 1 parameter, i got : "reference to evaluate is ambiguous both method evaluate(java.lang.Object...) in org.codehaus.janino.ExpressionEvaluator and method evaluate(int,java.lang.Object...) in org.codehaus.janino.ExpressionEvaluator match" for example:

This will throw error:

    var stringExpression = "x + y + 10 + 100";
    var ee = new ExpressionEvaluator(
            stringExpression,
            long.class,
            new String[]{"x", "y"},
            new Class[]{int.class, int.class});
    var res = t.evaluate(1, 2);

Is this a bug or i did something wrong? Thank you.

aunkrig commented 1 year ago

Fixed it; please test.

Notice: In version 3.1.8, the arguments parameter was changed from Object[] to Object..., which turned out to be a really bad decision because it caused a very ugly invocation ambiguity with evaluate(int, Object[]). Thus, with version 3.1.10, the parameter was changed back to Object[].

aunkrig commented 1 year ago

Ping.

aunkrig commented 10 months ago

Ping.