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

Fail to resolve method reference with generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.18, 4.0.12
    • Static Type Checker
    • None

    Description

      I have the following program

      import java.util.List;
      import java.util.function.Predicate;
      
      
      class Main {
        static final <T> void test() {
      
          List<T> x = null;
          Predicate<? super T> y = x::add;
      
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 9: Failed to find method 'add(T)' for the type: java.util.List<T> @ line 9, column 30.
             Predicate<? super T> y = x::add;
                                      ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master (commit: a29ce1ce64d565526b70e145ace665dd0617ec9b)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: