Thodoris Sotiropoulos created GROOVY-10961:
----------------------------------------------
Summary: STC rejects program when having SAM types and conditionals
Key: GROOVY-10961
URL: https://issues.apache.org/jira/browse/GROOVY-10961
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code}
import java.util.function.*;
import java.util.Deque;
class Main {
static final void test(Deque<Integer> p1, Supplier<Integer> p2) {
Supplier<Integer> x = (true) ? p1::peek : p2;
}
}
{code}
h3. Actual behavior
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 8: [Static type checking] - Cannot assign value of type
java.lang.Object to variable of type
java.util.function.Supplier<java.lang.Integer>
@ line 8, column 27.
Supplier<Integer> x = (true) ? p1::peek : p2;
^
1 error
{code}
h3. Expected behavior
Compile successfully
Tested against master (commit: ee93378e5c9560032284b66d33af440884c8505f)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)