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

Why implicitly call of the inner class instance not allowed?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4.18
    • None
    • None

    Description

      A parent and inner child classes:

      class Parent {
          def name
          def child = new Child()
          def call() {
              println('parent called')
          }
      }
      
      class Child {
          def call() {
              println('child called')
         }
      }
      

      Calling:

      import base.Parent
      
      parent = new Parent(name: 'parent')
      parent()
      parent.child.call()
      parent.child()
      

      output:

      parent called
      child called
      Caught: groovy.lang.MissingMethodException: No signature of method: base.Parent.child() is applicable for argument types: () values: []
      Possible solutions: call(), find(), find(groovy.lang.Closure), getChild(), setChild(java.lang.Object), split(groovy.lang.Closure)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            gekm gekm
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: