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

@Delegate's dealing with static methods seems incorrect

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.4, 1.8-beta-1
    • Fix Version/s: 1.7.4, 1.8-beta-1
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: