[ https://issues.apache.org/jira/browse/GROOVY-7509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14647669#comment-14647669 ]
ASF GitHub Bot commented on GROOVY-7509: ---------------------------------------- Github user keeganwitt commented on a diff in the pull request: https://github.com/apache/incubator-groovy/pull/76#discussion_r35874858 --- Diff: src/test/org/codehaus/groovy/tools/stubgenerator/ImportStaticAliasTest.groovy --- @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.codehaus.groovy.tools.stubgenerator + +class ImportStaticAliasTest extends StringSourcesStubTestCase { + + Map<String, String> provideSources() { + [ + 'Constants.java': ''' + package test; + public class Constants { + public static final String C1 = "c1"; + } + ''', + + 'MyAnnotation.java': ''' + package test; + public @interface MyAnnotation { + String value(); + } + ''', + + 'Test.groovy': ''' + package test + import static test.Constants.C1 as C2 + @MyAnnotation(C2) + class Test { + def test + Test(test) { + this.test = test + } + } + ''', + + 'SomeJavaClass.java': ''' + package test; + public class SomeJavaClass { + Test test; + } + ''' + ] + } + + void verifyStubs() { + --- End diff -- I think you forgot to add your assertions. > 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)