Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8-beta-1
-
None
Description
The following code compiles fine:
import java.util.concurrent.* class Test { def bar () { ExecutorService pool = null pool.submit(( Runnable ) [ run : { "some statement"; //println "fishy print" }]) } }
But if I uncomment the print statement from inside the closure, like
import java.util.concurrent.* class Test { def bar () { ExecutorService pool = null pool.submit(( Runnable ) [ run : { "some statement"; println "fishy print" }]) } }
I get the following compilation error:
...\Try.groovy: 5: You tried to use a map entry for an index operation, this is not allowed. Maybe something should be set in parentheses or a comma is missing? @ line 5, column 36. pool.submit(( Runnable ) [ run : { "some statement";
Here is the AST formed in 2 cases (2nd case has the wrong AST)
Case 1: (Successful compilation)
ArgumentListExpression[ CastExpression[ (java.lang.Runnable) MapExpression[ MapEntryExpression(key: ConstantExpression[run], value: ClosureExpression[]{...} ) ] ] ]
Case 2: (Failing compilation)
ArgumentListExpression[ BinaryExpression[ left = ClassExpression[type: java.lang.Runnable] operation = "[" right = MapEntryExpression(key: ConstantExpression[run], value: ClosureExpression[]{...})]]