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

Traits enhancement should rename static methodMissing and propertyMissing to static versions when weaving methods

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • 2.4.8
    • Compiler
    • None

    Description

      Given:

      trait Foo {
         static methodMissing(String name, args) {
              println name
         }
      }
      class Bar implements Foo{}
      
      Bar.callMe()
      

      The above produces a MissingMethodException. Since the methodMissing definition is static the method should be renamed to `$static_methodMissing` (and `$static_propertyMissing` for the property version) to align them with the internal methods:

      https://github.com/apache/incubator-groovy/blob/master/src/main/groovy/lang/MetaClassImpl.java#L108

      Note that defining:

      trait Foo {
         static $static_methodMissing(String name, args) {
              println name
         }
      }
      class Bar implements Foo{}
      
      Bar.callMe()
      

      Does not work either, so currently there is no way to define a static method missing without involving an AST transform.

      Attachments

        Activity

          People

            paulk Paul King
            graemerocher1 Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: