Skip to content

Commit

Permalink
GROOVY-10159
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 9, 2021
1 parent 463ecb7 commit 01cc9ac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,23 @@ public void testStaticProperty14() {
"----------\n");
}

@Test // GROOVY-10159
public void testStaticProperty15() {
//@formatter:off
String[] sources = {
"Main.groovy",
"public class Main {\n" +
" static final String foo = 1 + 1\n" +
" static main(args) {\n" +
" print(foo);\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "2");
}

@Test
public void testClash_GRE1076() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public static ConstantExpression transformBinaryConstantExpression(BinaryExpress
Expression left = transformInlineConstants(be.getLeftExpression(), targetType);
Expression right = transformInlineConstants(be.getRightExpression(), targetType);
if (left instanceof ConstantExpression && right instanceof ConstantExpression) {
// GRECLIPSE add -- GROOVY-10159
if (((ConstantExpression) left).getValue() instanceof String)
// GRECLIPSE end
return configure(be, new ConstantExpression((String) ((ConstantExpression) left).getValue() +
((ConstantExpression) right).getValue()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public static ConstantExpression transformBinaryConstantExpression(final BinaryE
Expression left = transformInlineConstants(be.getLeftExpression(), targetType);
Expression right = transformInlineConstants(be.getRightExpression(), targetType);
if (left instanceof ConstantExpression && right instanceof ConstantExpression) {
// GRECLIPSE add -- GROOVY-10159
if (((ConstantExpression) left).getValue() instanceof String)
// GRECLIPSE end
return configure(be, new ConstantExpression((String) ((ConstantExpression) left).getValue() + ((ConstantExpression) right).getValue()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public static ConstantExpression transformBinaryConstantExpression(final BinaryE
Expression left = transformInlineConstants(be.getLeftExpression(), targetType);
Expression right = transformInlineConstants(be.getRightExpression(), targetType);
if (left instanceof ConstantExpression && right instanceof ConstantExpression) {
// GRECLIPSE add -- GROOVY-10159
if (((ConstantExpression) left).getValue() instanceof String)
// GRECLIPSE end
return configure(be, new ConstantExpression((String) ((ConstantExpression) left).getValue() + ((ConstantExpression) right).getValue()));
}
}
Expand Down

0 comments on commit 01cc9ac

Please sign in to comment.