Skip to content

Commit

Permalink
GROOVY-8693, GROOVY-10380, GROOVY-10381
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Nov 26, 2021
1 parent 363d640 commit 2228742
Show file tree
Hide file tree
Showing 8 changed files with 2,941 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,40 @@ public void testCompileStatic8686b() {
"----------\n");
}

@Test
public void testCompileStatic8693() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class C extends p.A {\n" +
" void m() {\n" +
" super.m()\n" + // StackOverflowError
" }\n" +
" void test() {\n" +
" m()\n" +
" }\n" +
"}\n" +
"new C().test()\n",

"p/A.java",
"package p;\n" +
"public abstract class A implements I {\n" +
"}\n",

"p/I.java",
"package p;\n" +
"public interface I {\n" +
" default void m() {\n" +
" System.out.print(\"works\");\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "works");
}

@Test
public void testCompileStatic8816() {
//@formatter:off
Expand Down Expand Up @@ -6236,6 +6270,44 @@ public void testCompileStatic9893a() {
runConformTest(sources, "String");
}

@Test(expected = AssertionError.class)
public void testCompileStatic9909() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import p.*\n" +
"@groovy.transform.CompileStatic\n" +
"class C implements A, B {\n" +
" void m() {\n" +
" A.super.m()\n" +
" }\n" +
" void test() {\n" +
" m()\n" +
" }\n" +
"}\n" +
"new C().test()\n",

"p/A.java",
"package p;\n" +
"public interface A {\n" +
" default void m() {\n" +
" System.out.print(\"A\");\n" +
" }\n" +
"}\n",

"p/B.java",
"package p;\n" +
"public interface B {\n" +
" default void m() {\n" +
" System.out.print(\"B\");\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "A");
}

@Test
public void testCompileStatic9918() {
//@formatter:off
Expand Down Expand Up @@ -6786,4 +6858,73 @@ public void testCompileStatic10379() {

runConformTest(sources, "string");
}

@Test
public void testCompileStatic10380() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class C extends p.A {\n" +
" void test() {\n" +
" m()\n" + // IncompatibleClassChangeError: Found class C, but interface was expected
" }\n" +
"}\n" +
"new C().test()\n",

"p/A.groovy",
"package p\n" +
"abstract class A implements I {\n" +
"}\n",

"p/I.java",
"package p;\n" +
"interface I {\n" +
" default void m() {\n" +
" System.out.print(\"works\");\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "works");
}

@Test
public void testCompileStatic10381() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class C implements p.A, p.B {\n" +
" void test() {\n" +
" m()\n" +
" }\n" +
"}\n" +
"new C().test()\n",

"p/A.java",
"package p;\n" +
"public interface A {\n" +
" default void m() {\n" +
" }\n" +
"}\n",

"p/B.java",
"package p;\n" +
"public interface B {\n" +
" default void m() {\n" +
" }\n" +
"}\n",
};
//@formatter:on

runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 2)\n" +
"\tclass C implements p.A, p.B {\n" +
"\t ^\n" +
"Duplicate default methods named m with the parameters () and () are inherited from the types A and B\n" +
"----------\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,40 @@ public void testTypeChecked8202() {
runConformTest(sources, "foobarbaznullnullnull");
}

@Test(expected = AssertionError.class)
public void testTypeChecked8693() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"class C extends p.A {\n" +
" void m() {\n" +
" super.m()\n" + // MissingMethodException
" }\n" +
" void test() {\n" +
" m()\n" +
" }\n" +
"}\n" +
"new C().test()\n",

"p/A.java",
"package p;\n" +
"public abstract class A implements I {\n" +
"}\n",

"p/I.java",
"package p;\n" +
"public interface I {\n" +
" default void m() {\n" +
" System.out.print(\"works\");\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "works");
}

@Test
public void testTypeChecked8909() {
//@formatter:off
Expand Down
1 change: 1 addition & 0 deletions base/org.codehaus.groovy25/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<file-match-pattern match-pattern="groovy/classgen/asm/BytecodeHelper.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/ClosureWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/CompileStack.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/InvocationWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/StatementMetaTypeChooser.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/(Optimizing)?StatementWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticInvocationWriter.java" include-pattern="false" />
Expand Down
Loading

0 comments on commit 2228742

Please sign in to comment.