This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 691ee27223 GROOVY-11241: add test case
691ee27223 is described below
commit 691ee27223f8ce6d8912e8985fd2d568d132cc73
Author: Eric Milles <[email protected]>
AuthorDate: Thu Dec 7 11:20:16 2023 -0600
GROOVY-11241: add test case
---
.../transform/stc/MethodReferenceTest.groovy | 42 ++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/src/test/groovy/transform/stc/MethodReferenceTest.groovy
b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
index 53a5802124..5e600732c9 100644
--- a/src/test/groovy/transform/stc/MethodReferenceTest.groovy
+++ b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
@@ -238,6 +238,48 @@ final class MethodReferenceTest {
'''
}
+ @Test // class::instanceMethod -- GROOVY-11241
+ void testFunctionCI9() {
+ assertScript imports + '''
+ @Grab('io.vavr:vavr:0.10.4')
+ import io.vavr.control.*
+
+ Option<Integer> option() { Option.of(42) }
+
+ @CompileStatic
+ Try<Integer> test() {
+ Try.of{ option() }.<Integer>mapTry(Option::get)
+ // ^^^^^^^^^
+ }
+
+ assert test().get() == 42
+ '''
+
+ def err = shouldFail imports + '''
+ @Grab('io.vavr:vavr:0.10.4')
+ import io.vavr.control.Try
+
+ class Option<X> {
+ private final X x
+ def X get() { x }
+ static <Y> Option<Y> of(Y y) {
+ new Option(x: y)
+ }
+ }
+
+ Option<Integer> option() { Option.of(666) }
+
+ @CompileStatic
+ Try<Integer> test() {
+ //Try.of { option() }.mapTry(Option::get)
+ def try_of = Try.of { option() }
+ def result = try_of.mapTry(Option::get)
+ result
+ }
+ '''
+ assert err =~ /Cannot (assign|return) io.vavr.control.Try
<java.lang.Object> / // not <X> or <Option<Integer>>
+ }
+
@Test // class::instanceMethod -- GROOVY-9974
void testPredicateCI() {
assertScript imports + '''