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

Cannot call private member of containing class in @CS

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.8
    • Fix Version/s: 3.0.0-rc-3
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      class C {
      
          private C() {}
          private privateMethod() {}
      
          def anonymousUsage() {
              new Runnable() {
                  @groovy.transform.CompileStatic
                  @Override
                  void run() {
                      privateMethod()
                      new C()
                  }
              }
          }
      }

      Expected: code is compiled without errors.
      Actual: 2  errors:
      Cannot call private method C#privateMethod from class C$1
      Cannot call private constructor for C from class C$1

      Note that Java compiles the same code just fine.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                daniilo Daniil Ovchinnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h