groovy
  1. groovy
  2. GROOVY-3423

Imports of the form "import static SimpleClassName.*" cause compile error

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7-beta-1
    • Fix Version/s: 1.6.3, 1.7-beta-1
    • Component/s: Compiler
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      A.groovy:

      package foo
      
      class A {
        static bar() {}
      }
      

      B.groovy:

      package foo
      
      import static A.* // compile error: unable to resolve class A
      
      class B {
        def baz() {
          bar()
        }
      

      }

      "import static foo.A.*" and "import static A.bar" work as expected.

        Activity

        Hide
        Roshan Dawrani added a comment -

        It does not really seem to be related to import static feature because even compilation of the following fails.

        Pretty basic usage. Seems to be a serious bug!

        It can't see groovy classes of the same package!

        A.groovy

        package foo
        
        class A {}
        

        B.groovy

        package foo
        
        class B {
          def baz() {
            new A()
          }
        }
        
        Show
        Roshan Dawrani added a comment - It does not really seem to be related to import static feature because even compilation of the following fails. Pretty basic usage. Seems to be a serious bug! It can't see groovy classes of the same package! A.groovy package foo class A {} B.groovy package foo class B { def baz() { new A() } }
        Hide
        blackdrag blackdrag added a comment -

        for B to find A.groovy during compilation A.groovy has to be in a directory foo and the directory containing foo has to be in the classpath. Or both files have to be given to the compiler.

        Show
        blackdrag blackdrag added a comment - for B to find A.groovy during compilation A.groovy has to be in a directory foo and the directory containing foo has to be in the classpath. Or both files have to be given to the compiler.
        Hide
        blackdrag blackdrag added a comment -

        as for the static import.. I am a bit puzzled as of why A.bar works, but A.* does not.

        Show
        blackdrag blackdrag added a comment - as for the static import.. I am a bit puzzled as of why A.bar works, but A.* does not.
        Hide
        Roshan Dawrani added a comment -

        I see. I just put the files in the same directory but other things you said were not followed. I will put them there and re-try the original issue reported here.

        Show
        Roshan Dawrani added a comment - I see. I just put the files in the same directory but other things you said were not followed. I will put them there and re-try the original issue reported here.
        Hide
        Roshan Dawrani added a comment -

        Fixed.

        Show
        Roshan Dawrani added a comment - Fixed.

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Peter Niederwieser
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: