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

Static import of a static property causes joint compilation to fail

    XMLWordPrintableJSON

Details

    Description

      Due to the addition of static imports in generated stubs (per https://issues.apache.org/jira/browse/GROOVY-7366), the following test now fails:

      package org.codehaus.groovy.tools.stubgenerator
      
      
      class ImportStaticPropertyTest extends StringSourcesStubTestCase {
      
        @Override
        Map<String, String> provideSources() {
            [
                    'A.groovy': '''
                        package test
                        class A {
                            static String aString
                        }
                    ''',
      
                    'B.groovy': '''
                        package test
                        import static test.A.aString
                        class B {
                            String returnAString(){
                                return aString
                            }
                        }
                    ''',
      
                    'C.java': '''
                        package test;
                        public class C {
                            public static void main(String[] args) {
                                B b;
                            }
                        }
                    '''
            ]
        }
      
        @Override
        void verifyStubs() {
      
        }
      }
      

      The error produced is:

      error: cannot find symbol
      import static test.A.aString;
      ^
        symbol:   static aString
        location: class
      

      Adding a public modifier to aString will cause aString to be included in the generated stub for A, in which case the test will pass.

      Attachments

        Activity

          People

            emilles Eric Milles
            shils Shil Sinha
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: