Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-4370

Mixin a class with static methods is not working properly

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.4
    • None
    • groovy-runtime
    • None

    Description

      If a class with static methods is mixed in another class, the static methods are not available as static methods.
      Furthermore a strange behaviour occurs - they are available as instance methods and when once called as instance methods they also get available as static methods - see the code below.

      class Base {
          def instanceMethod() { println 'instance method' }
          static staticMethod() { println 'static method' }
      }
      
      class T1 {}
      class T2 {}
      
      T1.mixin Base
      T2.mixin Base
      
      t1 = new T1()
      t1.instanceMethod()
      t1.staticMethod()
      T1.staticMethod()   // somehow working, after callling it as an instance method before - thats' strange!!!
      
      t2 = new T2()
      t2.instanceMethod()
      T2.staticMethod()   // not working: Caught: groovy.lang.MissingMethodException: No signature of method: static T2.staticMethod() is applicable for argument types: () values
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rene.scheibe Rene Scheibe
            Votes:
            8 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated: