Skip to content

Commit 2228742

Browse files
committed
GROOVY-8693, GROOVY-10380, GROOVY-10381
1 parent 363d640 commit 2228742

File tree

8 files changed

+2941
-2
lines changed

8 files changed

+2941
-2
lines changed

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

+141
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,40 @@ public void testCompileStatic8686b() {
26032603
"----------\n");
26042604
}
26052605

2606+
@Test
2607+
public void testCompileStatic8693() {
2608+
//@formatter:off
2609+
String[] sources = {
2610+
"Main.groovy",
2611+
"@groovy.transform.CompileStatic\n" +
2612+
"class C extends p.A {\n" +
2613+
" void m() {\n" +
2614+
" super.m()\n" + // StackOverflowError
2615+
" }\n" +
2616+
" void test() {\n" +
2617+
" m()\n" +
2618+
" }\n" +
2619+
"}\n" +
2620+
"new C().test()\n",
2621+
2622+
"p/A.java",
2623+
"package p;\n" +
2624+
"public abstract class A implements I {\n" +
2625+
"}\n",
2626+
2627+
"p/I.java",
2628+
"package p;\n" +
2629+
"public interface I {\n" +
2630+
" default void m() {\n" +
2631+
" System.out.print(\"works\");\n" +
2632+
" }\n" +
2633+
"}\n",
2634+
};
2635+
//@formatter:on
2636+
2637+
runConformTest(sources, "works");
2638+
}
2639+
26062640
@Test
26072641
public void testCompileStatic8816() {
26082642
//@formatter:off
@@ -6236,6 +6270,44 @@ public void testCompileStatic9893a() {
62366270
runConformTest(sources, "String");
62376271
}
62386272

6273+
@Test(expected = AssertionError.class)
6274+
public void testCompileStatic9909() {
6275+
//@formatter:off
6276+
String[] sources = {
6277+
"Main.groovy",
6278+
"import p.*\n" +
6279+
"@groovy.transform.CompileStatic\n" +
6280+
"class C implements A, B {\n" +
6281+
" void m() {\n" +
6282+
" A.super.m()\n" +
6283+
" }\n" +
6284+
" void test() {\n" +
6285+
" m()\n" +
6286+
" }\n" +
6287+
"}\n" +
6288+
"new C().test()\n",
6289+
6290+
"p/A.java",
6291+
"package p;\n" +
6292+
"public interface A {\n" +
6293+
" default void m() {\n" +
6294+
" System.out.print(\"A\");\n" +
6295+
" }\n" +
6296+
"}\n",
6297+
6298+
"p/B.java",
6299+
"package p;\n" +
6300+
"public interface B {\n" +
6301+
" default void m() {\n" +
6302+
" System.out.print(\"B\");\n" +
6303+
" }\n" +
6304+
"}\n",
6305+
};
6306+
//@formatter:on
6307+
6308+
runConformTest(sources, "A");
6309+
}
6310+
62396311
@Test
62406312
public void testCompileStatic9918() {
62416313
//@formatter:off
@@ -6786,4 +6858,73 @@ public void testCompileStatic10379() {
67866858

67876859
runConformTest(sources, "string");
67886860
}
6861+
6862+
@Test
6863+
public void testCompileStatic10380() {
6864+
//@formatter:off
6865+
String[] sources = {
6866+
"Main.groovy",
6867+
"@groovy.transform.CompileStatic\n" +
6868+
"class C extends p.A {\n" +
6869+
" void test() {\n" +
6870+
" m()\n" + // IncompatibleClassChangeError: Found class C, but interface was expected
6871+
" }\n" +
6872+
"}\n" +
6873+
"new C().test()\n",
6874+
6875+
"p/A.groovy",
6876+
"package p\n" +
6877+
"abstract class A implements I {\n" +
6878+
"}\n",
6879+
6880+
"p/I.java",
6881+
"package p;\n" +
6882+
"interface I {\n" +
6883+
" default void m() {\n" +
6884+
" System.out.print(\"works\");\n" +
6885+
" }\n" +
6886+
"}\n",
6887+
};
6888+
//@formatter:on
6889+
6890+
runConformTest(sources, "works");
6891+
}
6892+
6893+
@Test
6894+
public void testCompileStatic10381() {
6895+
//@formatter:off
6896+
String[] sources = {
6897+
"Main.groovy",
6898+
"@groovy.transform.CompileStatic\n" +
6899+
"class C implements p.A, p.B {\n" +
6900+
" void test() {\n" +
6901+
" m()\n" +
6902+
" }\n" +
6903+
"}\n" +
6904+
"new C().test()\n",
6905+
6906+
"p/A.java",
6907+
"package p;\n" +
6908+
"public interface A {\n" +
6909+
" default void m() {\n" +
6910+
" }\n" +
6911+
"}\n",
6912+
6913+
"p/B.java",
6914+
"package p;\n" +
6915+
"public interface B {\n" +
6916+
" default void m() {\n" +
6917+
" }\n" +
6918+
"}\n",
6919+
};
6920+
//@formatter:on
6921+
6922+
runNegativeTest(sources,
6923+
"----------\n" +
6924+
"1. ERROR in Main.groovy (at line 2)\n" +
6925+
"\tclass C implements p.A, p.B {\n" +
6926+
"\t ^\n" +
6927+
"Duplicate default methods named m with the parameters () and () are inherited from the types A and B\n" +
6928+
"----------\n");
6929+
}
67896930
}

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

+34
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,40 @@ public void testTypeChecked8202() {
13521352
runConformTest(sources, "foobarbaznullnullnull");
13531353
}
13541354

1355+
@Test(expected = AssertionError.class)
1356+
public void testTypeChecked8693() {
1357+
//@formatter:off
1358+
String[] sources = {
1359+
"Main.groovy",
1360+
"@groovy.transform.TypeChecked\n" +
1361+
"class C extends p.A {\n" +
1362+
" void m() {\n" +
1363+
" super.m()\n" + // MissingMethodException
1364+
" }\n" +
1365+
" void test() {\n" +
1366+
" m()\n" +
1367+
" }\n" +
1368+
"}\n" +
1369+
"new C().test()\n",
1370+
1371+
"p/A.java",
1372+
"package p;\n" +
1373+
"public abstract class A implements I {\n" +
1374+
"}\n",
1375+
1376+
"p/I.java",
1377+
"package p;\n" +
1378+
"public interface I {\n" +
1379+
" default void m() {\n" +
1380+
" System.out.print(\"works\");\n" +
1381+
" }\n" +
1382+
"}\n",
1383+
};
1384+
//@formatter:on
1385+
1386+
runConformTest(sources, "works");
1387+
}
1388+
13551389
@Test
13561390
public void testTypeChecked8909() {
13571391
//@formatter:off

base/org.codehaus.groovy25/.checkstyle

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<file-match-pattern match-pattern="groovy/classgen/asm/BytecodeHelper.java" include-pattern="false" />
4949
<file-match-pattern match-pattern="groovy/classgen/asm/ClosureWriter.java" include-pattern="false" />
5050
<file-match-pattern match-pattern="groovy/classgen/asm/CompileStack.java" include-pattern="false" />
51+
<file-match-pattern match-pattern="groovy/classgen/asm/InvocationWriter.java" include-pattern="false" />
5152
<file-match-pattern match-pattern="groovy/classgen/asm/StatementMetaTypeChooser.java" include-pattern="false" />
5253
<file-match-pattern match-pattern="groovy/classgen/asm/(Optimizing)?StatementWriter.java" include-pattern="false" />
5354
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticInvocationWriter.java" include-pattern="false" />

0 commit comments

Comments
 (0)