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

allow package keyword to appear in select places

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0-beta-2
    • Fix Version/s: 2.2.0-rc-1
    • Component/s: parser
    • Labels:
      None

      Description

      The JVM allows 'package' to be a valid name for a classfile but because package is a keyword, Groovy doesn't allow access to such classes. I propose to allow package to be used as an identifier if appearing in an import statement or if immediately followed by a '.'.

      After this change the following code would work:

      @Grab('org.scala-lang:scala-library:2.10.2')
      import scala.math.package as ScalaMath
      assert ScalaMath.sqrt(9.0d) == 3.0d
      import scala.sys.package
      assert package.env().keySet().contains('JAVA_HOME')
      assert package.name == 'scala.sys.package'
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                paulk Paul King
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: