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

Static import don't work in scripts in default packages

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.5
    • 1.7.6, 1.8-beta-3
    • None
    • None

    Description

      Test.groovy
      /* both the .* or .foo/.bar ways of static importing don't work
      import static Helper.*
      
      //import static Helper.foo
      //import static Helper.bar
       
      println foo() // fails MissingMethodException
      println bar // fails MissingPropertyException
      
      Helper.groovy
      class Helper {
          static foo(){
              println 'foo called'
          }
          static bar = 'bar'
      }
      

      But the following static import, which uses a class under a package, works:

      import static java.lang.Integer.*
      println MIN_VALUE
      

      Attachments

        Activity

          People

            paulk Paul King
            roshandawrani Roshan Dawrani
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: