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

Exception with inheritance and private method calls from a closure

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.5.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The test 'testClosureCallWithPrivateMethod' fails with Groovy 1.5.1 and 1.5.2 (I don't know about the other versions). It should not fail.

      class Parent {
          void publicMethod1() {
              privateMethod()
          }
      
          void publicMethod2() {
              [''].each { privateMethod()}
          }
      
          void publicMethod3() {
              [''].each { protectedMethod()} 
          }
      
          private void privateMethod() {}
      
          protected void protectedMethod() {}
      }
      
      class Child extends Parent {}
      
      class ClosureMethodCallTest extends GroovyTestCase {
          void testDirectCall() {
              // No exceptions means the test passes
              new Child().publicMethod1()
          }
          
          void testClosureCallWithPrivateMethod() {
              // No exceptions means the test passes
              new Child().publicMethod2()
          }
      
          void testClosureCallWithProtectedMethod() {
              // No exceptions means the test passes
              new Child().publicMethod3()
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                blackdrag Jochen Theodorou
                Reporter:
                hans_d Hans Dockter
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: