diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java index 4d4750a7bd..f01560d7e9 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java @@ -5922,6 +5922,9 @@ public void testInnerClass1() { " }\n" + " public java.lang.Object run() {\n" + " new Runnable() {\n" + + " x() {\n" + + " super();\n" + + " }\n" + " public void run() {\n" + " }\n" + " };\n" + @@ -5949,6 +5952,9 @@ public void testInnerClass1a() { checkGCUDeclaration("A.groovy", "public class A {\n" + " private java.lang.Object foo = new Runnable() {\n" + + " x() {\n" + + " super();\n" + + " }\n" + " public void run() {\n" + " }\n" + " };\n" + diff --git a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyClassScope.java b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyClassScope.java index c418885f9b..161d0375b9 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyClassScope.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyClassScope.java @@ -361,7 +361,17 @@ public void buildFieldsAndMethods() { } for (GroovyTypeDeclaration anonType : ((GroovyTypeDeclaration) referenceContext).getAnonymousTypes()) { - anonType.scope = new GroovyClassScope(this, anonType); + if (anonType.scope == null) { + if (anonType.getClassNode().isEnum()) { + anonType.scope = new GroovyClassScope(this, anonType); + // TODO: anonType.resolve(anonType.scope.parent); or ? + } else { + anonType.enclosingScope.parent = this; + anonType.allocation.resolveType(anonType.enclosingScope); + assert anonType.binding != null && anonType.scope != null; + // TODO: Replace anonType.scope with new GroovyClassScope? + } + } } } diff --git a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitDeclaration.java b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitDeclaration.java index 2295681d72..3ef269630a 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitDeclaration.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitDeclaration.java @@ -1157,6 +1157,7 @@ private void createTypeDeclarations(ModuleNode moduleNode) { innersToRecord.computeIfAbsent(outerClassNode, x -> new ArrayList<>()).add(typeDeclaration); if (innerClassNode.isAnonymous()) { + typeDeclaration.name = CharOperation.NO_CHAR; typeDeclaration.bits |= (ASTNode.IsAnonymousType | ASTNode.IsLocalType); typeDeclaration.bits |= (typeDeclaration.superclass.bits & ASTNode.HasTypeAnnotations); QualifiedAllocationExpression allocation = new QualifiedAllocationExpression(typeDeclaration);