Details

    • Type: Wish Wish
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.3, 1.8-beta-1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Describe a class

      class Foo {
        static def getBar(){}
        static def setBar(def bar){}
      }
      

      and a script

      import static Foo.bar
      
      print bar
      print getBar()
      

      Now 'print getBar()' throws MissingMethodException.
      IMHO 'getBar()' should be resolved to Foo.getBar() without explicit import

      The same thing is with setters and aliased imports.

      import static Foo.bar
      
      setBar(2)
      
       
      import static Foo.bar as baz
      
      setBaz(2)
      print getBaz()
      
      import static Foo.getBar
      
      print bar
      
      import static Foo.setBar
      
      bar = 2
      

        Issue Links

          Activity

          Hide
          Paul King added a comment -

          Initial support for statically importing properties is now in trunk and the 1_7_X branch. It still needs some finessing when public fields and property accessors are used in combo but I wanted to give others the chance to test usage for normal properties.

          Show
          Paul King added a comment - Initial support for statically importing properties is now in trunk and the 1_7_X branch. It still needs some finessing when public fields and property accessors are used in combo but I wanted to give others the chance to test usage for normal properties.
          Hide
          Paul King added a comment -

          Now working for public fields as well.

          Show
          Paul King added a comment - Now working for public fields as well.
          Hide
          Maxim Medvedev added a comment -

          It doesn't work for boolean properties and isFoo() getters

          Show
          Maxim Medvedev added a comment - It doesn't work for boolean properties and isFoo() getters
          Hide
          Guillaume Laforge added a comment -

          Perhaps it's also related to GROOVY-4206 ?

          Show
          Guillaume Laforge added a comment - Perhaps it's also related to GROOVY-4206 ?
          Hide
          Maxim Medvedev added a comment -

          I mean isBar() is not resolved in static import context.

          class Foo {
            static boolean bar = true
          }
          
          import static Foo.bar
          
          print isBar() //MissingMethodException is thrown
          
          Show
          Maxim Medvedev added a comment - I mean isBar() is not resolved in static import context. class Foo { static boolean bar = true } import static Foo.bar print isBar() //MissingMethodException is thrown
          Hide
          Maxim Medvedev added a comment -

          I've used Groovy 1.7.3

          Show
          Maxim Medvedev added a comment - I've used Groovy 1.7.3
          Hide
          Guillaume Laforge added a comment -

          When you say you're using Groovy 1.7.3, you mean a snapshot we publish, or built yourself? (1.7.3 hasn't yet been released! or are you coming from the future?

          Show
          Guillaume Laforge added a comment - When you say you're using Groovy 1.7.3, you mean a snapshot we publish, or built yourself? (1.7.3 hasn't yet been released! or are you coming from the future?
          Hide
          Maxim Medvedev added a comment -

          I'm using published snapshot but nevertheless I'm from future

          Show
          Maxim Medvedev added a comment - I'm using published snapshot but nevertheless I'm from future
          Hide
          Paul King added a comment -

          Yes, the solution didn't cover that case previously but has now been enhanced to cover that case as well. If you could check with the latest snapshot jar once bamboo has had time to do its thing, that would be great.

          Show
          Paul King added a comment - Yes, the solution didn't cover that case previously but has now been enhanced to cover that case as well. If you could check with the latest snapshot jar once bamboo has had time to do its thing, that would be great.

            People

            • Assignee:
              Paul King
              Reporter:
              Maxim Medvedev
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: