phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

Extra semicolon when returning lambda #53

Closed heruan closed 7 years ago

heruan commented 7 years ago

I don't know if this is a bug or I'm doing something wrong, but I can't find examples for lambdas so this is it:

JMethod method = definedClass.method(...);
JLambdaMethodRef methodLambda = new JLambdaMethodRef(...);
JLambda lambda = new JLambda();
lambda.body().lambdaExpr(
    JExpr._this().invoke("getValueProvider").invoke("andThen").arg(methodLambda)
);
method.body()._return(lambda);

This produces:

public default StringFilter<T> description() {
    return () -> this.getValueProvider().andThen(Category::getDescription);
    ; // <- Unreachable code error!
}

with the extra ; resulting in an "Unreachable code" error in Eclipse. How can I avoid the extra semicolon?

phax commented 7 years ago

You are using version 2.8.6 or 3.0.0 SNAPSHOT?

heruan commented 7 years ago

Thank you for the (impressive) responsiveness! I'm on 2.8.6 from Maven Central, but if you have a snapshot repository I'll try 3.0.0 right away.

phax commented 7 years ago

NP. 3.0.0 requires Java 8 - is this a problem?

heruan commented 7 years ago

Absolutely not, the project's 1.8 -> 1.8. Does 3.0.0 already address this?

phax commented 7 years ago

I'm not sure :) Just want to know whether I potentially need a backport or whether I can check in the latest only :) - give me a few minutes....

heruan commented 7 years ago

I managed to test it with current 3.0.0 and the output is the same: extra semicolon.

phax commented 7 years ago

I saw it. There are multiple issues to address... Stay tuned

phax commented 7 years ago

Sorry - no solution today :( I don't have too much time right now, but will address it asap

phax commented 7 years ago

Well I proved myself wrong - now working. Please cross check - Travis build should be available soon

heruan commented 7 years ago

Awesome, it works! Hope to see the fix on a Maven release soon. Thank you very much!