Skip to content

Commit

Permalink
GROOVY-9524
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 18, 2021
1 parent ae69b14 commit f803e4a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4917,6 +4917,32 @@ public void testCompileStatic9517() {
runConformTest(sources, "works");
}

@Test
public void testCompileStatic9524() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class W {\n" +
" enum X {\n" +
" Y {\n" +
" def z() {\n" +
" truncate('123', 2)\n" +
" }\n" +
" }\n" +
" abstract def z()\n" +
" private String truncate(String input, int maxLength) {\n" +
" input.substring(0, maxLength)\n" +
" }\n" +
" }\n" +
"}\n" +
"print W.X.Y.z()\n",
};
//@formatter:on

runConformTest(sources, "12");
}

@Test
public void testCompileStatic9555() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ protected boolean tryBridgeMethod(MethodNode target, Expression receiver, boolea
Expression fixedReceiver = receiver;
if (implicitThis) {
if (!controller.isInClosure()) {
// GRECLIPSE add -- GROOVY-9524
if (!thisClass.isDerivedFrom(lookupClassNode))
// GRECLIPSE end
fixedReceiver = new PropertyExpression(new ClassExpression(lookupClassNode), "this");
} else if (thisClass != null) {
ClassNode current = thisClass.getOuterClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ protected boolean tryBridgeMethod(final MethodNode target, final Expression rece
Expression fixedReceiver = receiver;
if (implicitThis) {
if (!controller.isInGeneratedFunction()) {
// GRECLIPSE add -- GROOVY-9524
if (!thisClass.isDerivedFrom(lookupClassNode))
// GRECLIPSE end
fixedReceiver = propX(classX(lookupClassNode), "this");
} else if (thisClass != null) {
ClassNode current = thisClass.getOuterClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ protected boolean tryBridgeMethod(final MethodNode target, final Expression rece
Expression fixedReceiver = receiver;
if (implicitThis) {
if (!controller.isInGeneratedFunction()) {
// GRECLIPSE add -- GROOVY-9524
if (!thisClass.isDerivedFrom(lookupClassNode))
// GRECLIPSE end
fixedReceiver = propX(classX(lookupClassNode), "this");
} else if (thisClass != null) {
ClassNode current = thisClass.getOuterClass();
Expand Down

0 comments on commit f803e4a

Please sign in to comment.