diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/AnnotationsTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/AnnotationsTests.java index a7d4484d33..277d75880c 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/AnnotationsTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/AnnotationsTests.java @@ -1085,7 +1085,7 @@ public void testLocalAnnotationClassLiteral() { runConformTest(sources); } - @Test + @Test // https://issues.apache.org/jira/browse/GROOVY-8063 public void testLocalAnnotationClassLiteral2() { //@formatter:off String[] sources = { @@ -1104,17 +1104,7 @@ public void testLocalAnnotationClassLiteral2() { }; //@formatter:on - runNegativeTest(sources, "----------\n" + - "1. ERROR in Main.groovy (at line 1)\n" + - "\t@Anno(Inner)\n" + - "\t ^^^^^\n" + - "Inner cannot be resolved\n" + - "----------\n" + - "2. ERROR in Main.groovy (at line 1)\n" + - "\t@Anno(Inner)\n" + - "\t ^^^^^\n" + - "Inner cannot be resolved or is not a field\n" + - "----------\n"); + runNegativeTest(sources, ""); } @Test diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/InnerClassTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/InnerClassTests.java index fe5a2817dd..9cabe09aea 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/InnerClassTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/InnerClassTests.java @@ -159,6 +159,30 @@ public void testInnerTypeReferencing6() { runConformTest(sources, "VALUE"); } + @Test // https://github.com/groovy/groovy-eclipse/issues/1300 + public void testInnerTypeReferencing7() { + //@formatter:off + String[] sources = { + "Main.java", + "public class Main {\n" + + " public static void main(String[] args) {\n" + + " Outer.Inner result = new Outer().getResult();\n" + + " }\n" + + "}\n", + + "Types.groovy", + "class Outer extends Type {\n" + // unqualified reference to Inner + " static class Inner { }\n" + + "}\n" + + "abstract class Type {\n" + + " T result\n" + + "}\n", + }; + //@formatter:on + + runConformTest(sources); + } + @Test public void testInnerClass1() { //@formatter:off diff --git a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitScope.java b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitScope.java index adcc00b5be..dbbac0623b 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitScope.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitScope.java @@ -108,10 +108,10 @@ protected ImportBinding[] getDefaultImports() { * static class Inner {} * } */ - //for (SourceTypeBinding topLevelType : topLevelTypes) { - // if (topLevelType.hasMemberTypes()) // add synthetic import to help resolve inner types - // importBindings.add(new ImportBinding(topLevelType.compoundName, true, topLevelType, null)); - //} + for (SourceTypeBinding topLevelType : topLevelTypes) { + if (topLevelType.hasMemberTypes()) // add synthetic import to help resolve inner types + importBindings.add(new ImportBinding(topLevelType.compoundName, true, topLevelType, null)); + } defaultGroovyImports = importBindings.toArray(new ImportBinding[importBindings.size()]); }