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

Nested class of parent Java class is not resolved

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      bugs/A.java
      package bugs;
      
      public class A {
          public interface Inner {}
      }
      
      bugs/B.java
      package bugs;
      
      public class B {
          public interface Inner {}
      }
      
      bugs/test/test.groovy
      package bugs.test
      
      import bugs.A
      //import static bugs.B.Inner
      
      class Current extends A {
        static usage() {
          return Inner // here
        }
      }
      
      println Current.usage()
      
      Apparent variable 'Inner' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
      You attempted to reference a variable in the binding or an instance variable from a static context.
      You misspelled a classname or statically imported field. Please check the spelling.
      You attempted to use a method 'Inner' but left out brackets in a place not allowed by the grammar.
       @ line 8, column 12.
             return Inner
                    ^
      

      Note the class could be resolved only via import.

      Now try to uncomment a static import.
      While usually the nested class takes precedence over an import, in this case the failure to resolve a nested class results in a silent resolution to bugs.B.Inner, i.e. no error is reported.

      In both cases the reference is expected to be resolved to bugs.A.Inner

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              daniilo Daniil Ovchinnikov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: