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

Mixins ignore private methods from superclasses

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-rc-1
    • 1.6-rc-2
    • None
    • None

    Description

      class A {

      def final foo()

      { bar() }

      private final String bar()

      { return "Bar" }

      }

      class B extends A {}

      class C {}

      C.metaClass {
      mixin B
      }

      def c= new C()
      c.foo()

      Running the script results in "Caught: groovy.lang.MissingMethodException: No signature of method: C.bar() is applicable for argument types: () values: {}". Changing the bar's visibility to non-private or mixing in A instead of B helps here.
      I assume the problem is that bar() is not directly visible in B, but since I'm calling bar() from foo(), which is defined in A, I would expect the code to work.
      Looks like calling private methods (bar) from inherited mixed-in methods (foo) is not possible?

      Attachments

        Activity

          People

            ait Alex Tkachman
            roller_vaclav Vaclav Pech
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: