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

ScriptMain.groovy: -1: Access to bugs.ClassWithInnerClass$InnerClass#obj is forbidden @ line -1, column -1.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.8, 3.0.0-beta-3
    • 3.0.0-rc-1
    • Static compilation
    • None

    Description

      bugs.ScriptMain.groovy:

      package bugs
      
      import groovy.transform.CompileStatic
      
      @CompileStatic
      public class ScriptMain {
          static void method(Closure closureToInvoke) {
              closureToInvoke.run()
          }
      
          public static void main(String[] args) {
              method({
                  def obj = new ClassWithInnerClass.InnerClass()
                  println obj.field
              })
          }
      }

      bugs.ClassWithInnerClass.java

      package bugs;
      
      public class ClassWithInnerClass {
          public static class InnerClass {
              public int field = 123;
          }
      }
      

      Errors out with:

      Access to bugs.ClassWithInnerClass$InnerClass#obj is forbidden @ line 14, column 21.
                     println obj.field 

      This works fine on groovy 2.5.6. But does not work neither 2.5.7, 2.5.8 nor 3.0.0-beta-3.

      This appears highly related to GROOVY-9005. However from what I can see that regression happens on 2.5.6 not on 2.5.7.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              ksaua Knut Saua Mathiesen
              Votes:
              0 Vote for this issue
              Watchers:
              5 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 - 40m
                  40m