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

Exception with inheritance and private method calls from a closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.5.2
    • None
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: