Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10975

STC rejects program when passing method reference in parameterized function

    XMLWordPrintableJSON

Details

    Description

      Probably a regression because groovyc 4.0.10 compiles the program.

      Program:

      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));
        }
      }
      

      Actual behavior

      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
      

      Expected behavior

      Compile successfully

      Tested against master (commit: d3c914693486bf137ec0992ef0dc28b79cba2fae)

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: