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

Fail to perform SAM conversion using method references

Details

    Description

      I have the following program

      import java.util.*;
      import java.util.stream.*;
      import java.util.function.*;
      
      
      class Main {
        static final void test(DoubleStream x, ObjDoubleConsumer<Boolean> y,
                               BiConsumer<Boolean, Boolean> z) {
              Spliterator.OfDouble d = null;
              StreamSupport.doubleStream(d, x.collect(
                  () -> true, y::accept, z::accept));
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 10: [Static type checking] - Cannot find matching method java.util.stream.StreamSupport#doubleStream(java.util.Spliterator$OfDouble, U). Please check if the declared type is correct and if the method exists.
       @ line 10, column 9.
                 StreamSupport.doubleStream(d, x.collect(
                 ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master (commit: d3c914693486bf137ec0992ef0dc28b79cba2fae)

      Attachments

        Issue Links

          Activity

            No work has yet been logged on this issue.

            People

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

              Dates

                Created:
                Updated:
                Resolved: