Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.6
-
None
Description
It seems that after coercing an object to a parameterized (generic) type containing a parameterized (generic) type as its only or last type argument without putting any space between the ending ">>", a semicolon is needed.
Example:
$ groovy -v
Groovy Version: 1.8.6 JVM: 1.6.0_30 Vendor: Sun Microsystems Inc. OS: Linux
$ groovy -e "def list = [1,2,3,4] as List<Integer>
println list
println 'bye'" # This works fine.
[1, 2, 3, 4]
bye
$ groovy -e "def list = [[1,2],[3,4]] as List<List<Integer>>
println list
println 'bye'" # This should work fine, but does not.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script_from_command_line: 2: expecting EOF, found 'println' @ line 2, column 1.
println list
^
1 error
$ groovy -e "def list = [[1,2],[3,4]] as List<List<Integer> >
println list
println 'bye'" # After adding a space between ">>", this works fine.
[[1, 2], [3, 4]]
bye
$ groovy -e "def list = [[1,2],[3,4]] as List<List<Integer>>;
println list
println 'bye'" # Or, after adding a semicolon, this works fine.
[[1, 2], [3, 4]]
bye
$
Attachments
Issue Links
- duplicates
-
GROOVY-8015 Strange groovy behavior
- Closed
- is duplicated by
-
GROOVY-7972 Strange compilation error with an "as" cast and a nested generics map
- Closed