Skip to content

Commit

Permalink
Update the Groovy plugin to 3.0.20
Browse files Browse the repository at this point in the history
GROOVY-7582, GROOVY-9852, GROOVY-9881 rollback

for #1524
  • Loading branch information
eric-milles committed Dec 19, 2023
1 parent aae7a6f commit 459b56b
Show file tree
Hide file tree
Showing 40 changed files with 1,003 additions and 2,285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package org.eclipse.jdt.core.groovy.tests.search;

import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isAtLeastGroovy;

import org.junit.Test;

public final class Groovy25InferencingTests extends InferencingTestSuite {
Expand Down Expand Up @@ -100,7 +98,7 @@ public void testCompileStaticVariableAssignment7() {
" Map map = [:]\n" +
"}\n";

assertType(contents, "map", "java.util.LinkedHashMap" + (!isAtLeastGroovy(40) ? "" : "<java.lang.Object,java.lang.Object>"));
assertType(contents, "map", "java.util.LinkedHashMap<java.lang.Object,java.lang.Object>");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected String[] getDefaultClassPaths() {
String[] cps = super.getDefaultClassPaths();
String[] newcps = Arrays.copyOf(cps, cps.length + 2);

String[] groovyVersions = {"5.0.0", "4.0.16", "3.0.19-indy"};
String[] groovyVersions = {"5.0.0", "4.0.16", "3.0.20-indy"};
String[] ivyVersions = {"2.5.2", "2.5.1", "2.5.0"};
try {
URL groovyJar = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2868,7 +2868,7 @@ public void testCompileStatic8499() {
"1. ERROR in Main.groovy (at line 3)\n" +
"\t[].stream().map{item,xxxx ->}\n" +
"\t ^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Wrong number of parameters for method target: apply(" + (isAtLeastGroovy(40) ? "java.lang.Object" : "E") + ")\n" +
"Groovy:[Static type checking] - Wrong number of parameters for method target: apply(java.lang.Object)\n" +
"----------\n");
}

Expand Down Expand Up @@ -3129,7 +3129,8 @@ public void testCompileStatic8686() {
};
//@formatter:on

runNegativeTest(sources, "----------\n" +
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 4)\n" +
"\tobj.toLowerCase()\n" +
"\t^^^^^^^^^^^^^^^^^\n" +
Expand All @@ -3150,7 +3151,8 @@ public void testCompileStatic8686a() {
};
//@formatter:on

runNegativeTest(sources, "----------\n" +
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 4)\n" +
"\tobj.toLowerCase()\n" +
"\t^^^^^^^^^^^^^^^^^\n" +
Expand Down Expand Up @@ -6644,6 +6646,46 @@ public void testCompileStatic9799() {
runConformTest(sources, "works");
}

@Test
public void testCompileStatic9852() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"void test() {\n" +
" Promise.promise().future()\n" + // STC is unaware of Promise return from future()
" .onSuccess({ print it }" + (isAtLeastGroovy(40) ? "" : " as Handler") + ")\n" +
"}\n" +
"test()\n",

"Future.groovy",
"interface Future<T> {\n" +
" Future<T> onSuccess(Handler<T> handler)\n" +
"}\n",

"Handler.groovy",
"interface Handler<E> {\n" +
" void handle(E event)\n" +
"}\n",

"Promise.groovy",
"class Promise<T> implements Future<T> {\n" +
" static <T> Promise<T> promise() { new Promise() }\n" +
" Future<T> future() { return this; }\n" +
" Future<T> onSuccess(Handler<T> h) {\n" +
" h.handle('works')\n" +
" return this\n" +
" }\n" +
" void onSuccess(T value) {\n" +
" print(value)\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "works");
}

@Test
public void testCompileStatic9853() {
assumeTrue(isParrotParser());
Expand Down Expand Up @@ -6758,8 +6800,8 @@ public void testCompileStatic9881() {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"void test() {\n" +
" print new Value<>(123).replace { -> 'foo' }\n" +
" print new Value<>(123).replace { Integer v -> 'bar' }\n" +
" print(new Value<>(123).replace { -> 'foo';})\n" +
" print(new Value<>(123).replace { Integer v -> 'bar';})\n" +
"}\n" +
"test()\n",

Expand All @@ -6783,7 +6825,22 @@ public void testCompileStatic9881() {
};
//@formatter:on

runConformTest(sources, "foobar");
if (isAtLeastGroovy(40)) {
runConformTest(sources, "foobar");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 3)\n" +
"\tprint(new Value<>(123).replace { -> 'foo';})\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [Value<T> Value<V>#replace(java.util.function.Supplier<T>), Value<T> Value<V>#replace(java.util.function.Function<? super V, ? extends T>)]\n" +
"----------\n" +
"2. ERROR in Main.groovy (at line 4)\n" +
"\tprint(new Value<>(123).replace { Integer v -> 'bar';})\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [Value<T> Value<V>#replace(java.util.function.Supplier<T>), Value<T> Value<V>#replace(java.util.function.Function<? super V, ? extends T>)]\n" +
"----------\n");
}
}

@Test
Expand All @@ -6795,8 +6852,8 @@ public void testCompileStatic9881a() {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"void test() {\n" +
" print new Value<>(123).replace(() -> 'foo')\n" +
" print new Value<>(123).replace((Integer v) -> 'bar')\n" +
" print(new Value<>(123).replace(() -> 'foo'))\n" +
" print(new Value<>(123).replace((Integer v) -> 'bar'))\n" +
"}\n" +
"test()\n",

Expand All @@ -6820,7 +6877,22 @@ public void testCompileStatic9881a() {
};
//@formatter:on

runConformTest(sources, "foobar");
if (isAtLeastGroovy(40)) {
runConformTest(sources, "foobar");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 3)\n" +
"\tprint(new Value<>(123).replace(() -> 'foo'))\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [Value<T> Value<V>#replace(java.util.function.Supplier<T>), Value<T> Value<V>#replace(java.util.function.Function<? super V, ? extends T>)]\n" +
"----------\n" +
"2. ERROR in Main.groovy (at line 4)\n" +
"\tprint(new Value<>(123).replace((Integer v) -> 'bar'))\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [Value<T> Value<V>#replace(java.util.function.Supplier<T>), Value<T> Value<V>#replace(java.util.function.Function<? super V, ? extends T>)]\n" +
"----------\n");
}
}

@Test
Expand Down Expand Up @@ -8255,7 +8327,17 @@ public void testCompileStatic11010() {
};
//@formatter:on

runConformTest(sources, "42");
if (xform.contains("Function") || isAtLeastGroovy(40)) {
runConformTest(sources, "42");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 7)\n" +
"\tprint(from(" + xform + "))\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [V Main#from(java.util.function.Function<K, V>), V Main#from(java.util.function.Supplier<V>)]\n" +
"----------\n");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1609,13 +1609,14 @@ public void testTypeChecked7582() {
" void x()\n" +
"}\n" +
"class C {\n" +
" void m(A a) { print 'fails' }\n" +
" @SuppressWarnings('rawtypes')\n" +
" void m(A a) { print 'wrong' }\n" +
" void m(B b) { print 'hello'; b.x() } \n" +
"}\n" +
"@groovy.transform.TypeChecked\n" +
"void test() {\n" +
" def c = new C()\n" +
" c.m { -> print ' world' }\n" +
" c.m { -> print(' world')}\n" +
"}\n" +
"test()\n",
};
Expand All @@ -1624,7 +1625,13 @@ public void testTypeChecked7582() {
if (isAtLeastGroovy(40)) {
runConformTest(sources, "hello world");
} else {
runConformTest(sources, "", "groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method C#m");
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 15)\n" +
"\tc.m { -> print(' world')}\n" +
"\t^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [void C#m(A), void C#m(B)]\n" +
"----------\n");
}
}

Expand Down Expand Up @@ -1942,7 +1949,7 @@ public void testTypeChecked8136() {
"1. ERROR in Main.groovy (at line 5)\n" +
"\tMVM m = [:]\n" +
"\t ^^^\n" +
"Groovy:[Static type checking] - Cannot find matching constructor MVM(java.util.LinkedHashMap" + (isAtLeastGroovy(40) ? "<#K, #V>" : "") + ")\n" +
"Groovy:[Static type checking] - Cannot find matching constructor MVM(java.util.LinkedHashMap<#K, #V>)\n" +
"----------\n");
}

Expand All @@ -1965,7 +1972,7 @@ public void testTypeChecked8136a() {
"1. ERROR in Main.groovy (at line 5)\n" +
"\tMVM m = [:]\n" +
"\t ^^^\n" +
"Groovy:[Static type checking] - Cannot find matching constructor MVM(java.util.LinkedHashMap" + (isAtLeastGroovy(40) ? "<#K, #V>" : "") + ")\n" +
"Groovy:[Static type checking] - Cannot find matching constructor MVM(java.util.LinkedHashMap<#K, #V>)\n" +
"----------\n");
}

Expand Down Expand Up @@ -3009,6 +3016,46 @@ public void testTypeChecked9844() {
runConformTest(sources, "[key:val][key:val]");
}

@Test
public void testTypeChecked9852() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"void test() {\n" +
" Promise.promise().future()\n" + // STC is unaware of Promise return from future()
" .onSuccess({ print it }" + (isAtLeastGroovy(40) ? "" : " as Handler") + ")\n" +
"}\n" +
"test()\n",

"Future.groovy",
"interface Future<T> {\n" +
" Future<T> onSuccess(Handler<T> handler)\n" +
"}\n",

"Handler.groovy",
"interface Handler<E> {\n" +
" void handle(E event)\n" +
"}\n",

"Promise.groovy",
"class Promise<T> implements Future<T> {\n" +
" static <T> Promise<T> promise() { new Promise() }\n" +
" Future<T> future() { return this; }\n" +
" Future<T> onSuccess(Handler<T> h) {\n" +
" h.handle('works')\n" +
" return this\n" +
" }\n" +
" void onSuccess(T value) {\n" +
" print(value)\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "works");
}

@Test
public void testTypeChecked9854() {
//@formatter:off
Expand Down Expand Up @@ -3072,6 +3119,56 @@ public void testTypeChecked9873() {
runConformTest(sources, "123", options);
}

@Test
public void testTypeChecked9881() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"void test() {\n" +
" print(new Value<>(123).replace { -> 'foo';})\n" +
" print(new Value<>(123).replace { Integer v -> 'bar';})\n" +
"}\n" +
"test()\n",

"Value.groovy",
"import java.util.function.*\n" +
"class Value<V> {\n" +
" final V val\n" +
" Value(V v) {\n" +
" this.val = v\n" +
" }\n" +
" String toString() {\n" +
" val as String\n" +
" }\n" +
" def <T> Value<T> replace(Supplier<T> supplier) {\n" +
" new Value<>(supplier.get())\n" +
" }\n" +
" def <T> Value<T> replace(Function<? super V, ? extends T> function) {\n" +
" new Value(function.apply(val))\n" +
" }\n" +
"}\n",
};
//@formatter:on

if (isAtLeastGroovy(40)) {
runConformTest(sources, "foobar");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 3)\n" +
"\tprint(new Value<>(123).replace { -> 'foo';})\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [Value<T> Value<V>#replace(java.util.function.Supplier<T>), Value<T> Value<V>#replace(java.util.function.Function<? super V, ? extends T>)]\n" +
"----------\n" +
"2. ERROR in Main.groovy (at line 4)\n" +
"\tprint(new Value<>(123).replace { Integer v -> 'bar';})\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between [Value<T> Value<V>#replace(java.util.function.Supplier<T>), Value<T> Value<V>#replace(java.util.function.Function<? super V, ? extends T>)]\n" +
"----------\n");
}
}

@Test
public void testTypeChecked9891() {
//@formatter:off
Expand Down
2 changes: 1 addition & 1 deletion base/org.codehaus.groovy30/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<file-match-pattern match-pattern="groovy/classgen/ExtendedVerifier.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/GeneratorContext.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/Verifier.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/(Invocation|Statement)Writer.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/StatementWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticInvocationWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticPropertyAccessHelper.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypes(CallSite|MethodReferenceExpression|Statement)Writer.java" include-pattern="false" />
Expand Down
8 changes: 4 additions & 4 deletions base/org.codehaus.groovy30/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<attribute name="javadoc_location" value="jar:platform:/resource/org.codehaus.groovy30/lib/ivy-2.5.2-javadoc.jar!/" />
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/groovy-3.0.19-indy.jar" sourcepath="lib/groovy-3.0.19-sources.jar" exported="true">
<classpathentry kind="lib" path="lib/groovy-3.0.20-indy.jar" sourcepath="lib/groovy-3.0.20-sources.jar" exported="true">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/org.codehaus.groovy30/lib/groovy-3.0.19-javadoc.jar!/" />
<attribute name="javadoc_location" value="jar:platform:/resource/org.codehaus.groovy30/lib/groovy-3.0.20-javadoc.jar!/" />
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/groovy-test-3.0.19-indy.jar" sourcepath="lib/groovy-test-3.0.19-sources.jar" exported="true">
<classpathentry kind="lib" path="lib/groovy-test-3.0.20-indy.jar" sourcepath="lib/groovy-test-3.0.20-sources.jar" exported="true">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/org.codehaus.groovy30/lib/groovy-test-3.0.19-javadoc.jar!/" />
<attribute name="javadoc_location" value="jar:platform:/resource/org.codehaus.groovy30/lib/groovy-test-3.0.20-javadoc.jar!/" />
</attributes>
</classpathentry>

Expand Down
Loading

0 comments on commit 459b56b

Please sign in to comment.