Skip to content

Commit 9d28ea6

Browse files
committed
GROOVY-6183
1 parent f15b79e commit 9d28ea6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,22 @@ public void testStaticProperty2() {
547547
runConformTest(sources, "");
548548
}
549549

550+
@Test
551+
public void testStaticProperty2a() {
552+
//@formatter:off
553+
String[] sources = {
554+
"Main.groovy",
555+
"class Main {\n" +
556+
" static main(args) {\n" +
557+
" this.@x\n" +
558+
" }\n" +
559+
"}\n",
560+
};
561+
//@formatter:on
562+
563+
runConformTest(sources, "", "java.lang.IncompatibleClassChangeError: Class java.lang.Class does not implement the requested interface groovy.lang.GroovyObject");
564+
}
565+
550566
@Test // GROOVY-8385
551567
public void testStaticProperty3() {
552568
//@formatter:off

base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/AsmClassGenerator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1039,9 +1039,8 @@ private void visitAttributeOrProperty(PropertyExpression expression, MethodCalle
10391039
field = classNode.getDeclaredField(name);
10401040
if (field == null && controller.isStaticContext()
10411041
&& expression instanceof AttributeExpression) {
1042-
// GROOVY-6183: checks supers
1043-
field = classNode.getField(name);
1044-
if (!field.isPublic() && !field.isProtected()) {
1042+
field = classNode.getField(name); // GROOVY-6183: check supers
1043+
if (field != null && !field.isPublic() && !field.isProtected()) {
10451044
field = null;
10461045
}
10471046
}

0 commit comments

Comments
 (0)