Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5652

Semicolon required after coercing to a parameterized (generic) type containing a parameterized (generic) type as its only or last type argument when there is no space between the ending ">>"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.6
    • 2.6.0-alpha-1
    • parser-antlr2
    • 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

          Activity

            People

              daniel_sun Daniel Sun
              adastragrl Amy Chuo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: