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

@Delegate's dealing with static methods seems incorrect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.4, 1.8-beta-1
    • 1.7.4, 1.8-beta-1
    • None
    • None

    Description

      @Delegate's dealing with static methods seems incorrect

      In the code below, shouldn't the call from B#main() go to C#foo()?

      If for a delegate method (which can only be an instance method), if the owner class has a static method, the delegate method should be the one used.

      A.groovy
      class A {
           static foo(){println "A->foo()"}
      }
      
      B.groovy
      class B extends A {
           @Delegate C c = new C()
           static main(args){
              new B().foo()
           }
      }
      
      C.groovy
      class C {
           def foo(){println "C->foo()"}
      }
      

      The above code outputs

      A->foo()
      

      but it should output

      C->foo()
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: