[ https://issues.apache.org/jira/browse/GROOVY-7509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14647711#comment-14647711 ]
Keegan Witt edited comment on GROOVY-7509 at 7/30/15 3:07 PM: -------------------------------------------------------------- It might be overkill, but I was thinking about something like this for the test {code:java|title=ImportStaticAliasTest.groovy} package org.codehaus.groovy.tools.stubgenerator class ImportStaticAliasTest extends StringSourcesStubTestCase { Map<String, String> provideSources() { [ 'Constants.groovy': ''' package test class Constants { static final String C1 = "c1" } ''', 'Methods.groovy': ''' package test class Methods { static void m1() {} } ''', 'Enums.groovy': ''' package test enum Enums { E1 } ''', 'Test.groovy': ''' package test import static Constants.C1 as C2 import static Methods.m1 as m2 import static Enums.E1 as E2 public class Test {} ''' ] } void verifyStubs() { def stubSource = stubJavaSourceFor('test.Test') assert stubSource.contains('import static Constants.C1') assert stubSource.contains('import static test.Methods.m1') assert stubSource.contains('import static test.Enums.E1') } } {code} was (Author: keegan): It might be overkill, but I was thinking about something like this for the test {code:java|title=ImportStaticAliasTest.groovy} package org.codehaus.groovy.tools.stubgenerator class ImportStaticAliasTest extends StringSourcesStubTestCase { Map<String, String> provideSources() { [ 'Constants.java': ''' package test class Constants { static final String C1 = "c1" } ''', 'Methods.groovy': ''' package test class Methods { static void m1() {} } ''', 'Enums.groovy': ''' package test enum Enums { E1 } ''', 'Test.groovy': ''' package test import static Constants.C1 as C2 import static Methods.m1 as m2 import static Enums.E1 as E2 public class Test {} ''' ] } void verifyStubs() { def stubSource = stubJavaSourceFor('test.Test') assert stubSource.contains('import static Constants.C1') assert stubSource.contains('import static Methods.m1') assert stubSource.contains('import static Enums.E1') } } {code} > Problem With Stub Generator And Static Import Aliases > ----------------------------------------------------- > > Key: GROOVY-7509 > URL: https://issues.apache.org/jira/browse/GROOVY-7509 > Project: Groovy > Issue Type: Bug > Components: Stub generator / Joint compiler > Affects Versions: 2.4.4 > Reporter: Jeff Scott Brown > Labels: regression > Attachments: staticimportalias.zip > > > The attached staticimportalias.zip contains the following: > {code:borderStyle=solid|title=src/main/groovy/demo/helper/SomeHelper.java} > package demo.helper; > public class SomeHelper { > public static final int ANSWER = 42; > } > {code} > {code:borderStyle=solid|title=src/main/groovy/demo/SomeClass.groovy} > package demo > import static demo.helper.SomeHelper.ANSWER as MAGIC_NUMBER > class SomeClass { > static int getMagicNumber() { > MAGIC_NUMBER > } > } > {code} > {code:borderStyle=solid|title=src/main/groovy/demo/SomeJavaClass.java} > package demo; > public class SomeJavaClass { > SomeClass sc; > } > {code} > The code will not compile with Groovy 2.4.4: > {noformat} > $ ./gradlew clean cG > :clean > :compileJava UP-TO-DATE > :compileGroovy > /Users/jeff/staticimportalias/build/tmp/groovy-java-stubs/demo/SomeClass.java:9: > error: cannot find symbol > import static demo.helper.SomeHelper.MAGIC_NUMBER; > ^ > symbol: static MAGIC_NUMBER > location: class > 1 error > startup failed: > Compilation failed; see the compiler error output for details. > 1 error > :compileGroovy FAILED > FAILURE: Build failed with an exception. > * What went wrong: > Execution failed for task ':compileGroovy'. > > Compilation failed; see the compiler error output for details. > * Try: > Run with --stacktrace option to get the stack trace. Run with --info or > --debug option to get more log output. > BUILD FAILED > Total time: 4.467 secs > {noformat} > If I edit the top level build.gradle to use Groovy 2.4.3, the code compiles. -- This message was sent by Atlassian JIRA (v6.3.4#6332)