Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
5.0.0-alpha-4, 4.0.17
-
None
-
None
Description
I have the following Groovy code and its Java equivalent:
@CompileStatic final class Main { private static final int ONE = 1 static void main(String[] args) { int two = ONE + 1 println two } }
public final class JavaMain { private static final int ONE = 1; public static void main(String[] args) { int two = ONE + 1; System.out.println(two); } }
In Groovy, it currently compiles to:
int two = ONE + 1
In Java, the calculation is done at compile-time and inlined:
int two = 2
It would be great if Groovy also did this.