Skip to content

Commit f803e4a

Browse files
committed
GROOVY-9524
1 parent ae69b14 commit f803e4a

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java

+26
Original file line numberDiff line numberDiff line change
@@ -4917,6 +4917,32 @@ public void testCompileStatic9517() {
49174917
runConformTest(sources, "works");
49184918
}
49194919

4920+
@Test
4921+
public void testCompileStatic9524() {
4922+
//@formatter:off
4923+
String[] sources = {
4924+
"Main.groovy",
4925+
"@groovy.transform.CompileStatic\n" +
4926+
"class W {\n" +
4927+
" enum X {\n" +
4928+
" Y {\n" +
4929+
" def z() {\n" +
4930+
" truncate('123', 2)\n" +
4931+
" }\n" +
4932+
" }\n" +
4933+
" abstract def z()\n" +
4934+
" private String truncate(String input, int maxLength) {\n" +
4935+
" input.substring(0, maxLength)\n" +
4936+
" }\n" +
4937+
" }\n" +
4938+
"}\n" +
4939+
"print W.X.Y.z()\n",
4940+
};
4941+
//@formatter:on
4942+
4943+
runConformTest(sources, "12");
4944+
}
4945+
49204946
@Test
49214947
public void testCompileStatic9555() {
49224948
//@formatter:off

base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java

+3
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ protected boolean tryBridgeMethod(MethodNode target, Expression receiver, boolea
242242
Expression fixedReceiver = receiver;
243243
if (implicitThis) {
244244
if (!controller.isInClosure()) {
245+
// GRECLIPSE add -- GROOVY-9524
246+
if (!thisClass.isDerivedFrom(lookupClassNode))
247+
// GRECLIPSE end
245248
fixedReceiver = new PropertyExpression(new ClassExpression(lookupClassNode), "this");
246249
} else if (thisClass != null) {
247250
ClassNode current = thisClass.getOuterClass();

base/org.codehaus.groovy30/src/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ protected boolean tryBridgeMethod(final MethodNode target, final Expression rece
246246
Expression fixedReceiver = receiver;
247247
if (implicitThis) {
248248
if (!controller.isInGeneratedFunction()) {
249+
// GRECLIPSE add -- GROOVY-9524
250+
if (!thisClass.isDerivedFrom(lookupClassNode))
251+
// GRECLIPSE end
249252
fixedReceiver = propX(classX(lookupClassNode), "this");
250253
} else if (thisClass != null) {
251254
ClassNode current = thisClass.getOuterClass();

base/org.codehaus.groovy40/src/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java

+3
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ protected boolean tryBridgeMethod(final MethodNode target, final Expression rece
248248
Expression fixedReceiver = receiver;
249249
if (implicitThis) {
250250
if (!controller.isInGeneratedFunction()) {
251+
// GRECLIPSE add -- GROOVY-9524
252+
if (!thisClass.isDerivedFrom(lookupClassNode))
253+
// GRECLIPSE end
251254
fixedReceiver = propX(classX(lookupClassNode), "this");
252255
} else if (thisClass != null) {
253256
ClassNode current = thisClass.getOuterClass();

0 commit comments

Comments
 (0)