Thodoris Sotiropoulos created GROOVY-10975:
----------------------------------------------
Summary: STC rejects program when passing method reference in
parameterized function
Key: GROOVY-10975
URL: https://issues.apache.org/jira/browse/GROOVY-10975
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
Probably a regression because groovyc 4.0.10 compiles the program.
Program:
{code}
import java.util.*;
class Main {
static final void test() {
Collection<Integer> x = null;
WeakHashMap<Integer, Integer> y = null;
new Hashtable<java.lang.IllegalStateException, Boolean>(Collections.min(x,
y::put));
}
}
{code}
h3. Actual behavior
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Main.groovy: 8: [Static type checking] - Cannot find matching constructor
java.util.Hashtable(java.lang.Object)
@ line 8, column 5.
new Hashtable<java.lang.IllegalStateException,
Boolean>(Collections.min(x, y::put));
^
1 error
{code}
h3. Expected behavior
Compile successfully
Tested against master (commit: d3c914693486bf137ec0992ef0dc28b79cba2fae)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)