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

Fail to find method reference in case of chain of polymorphic method calls

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Static Type Checker
    • None

    Description

      This is probably a regresssion.

      I have the following program

      import java.util.*;
      import java.util.concurrent.*;
      
      class Foo<K, V> {
        V apply(K p) { return null; }
      }
      
      class Main {
        static final void test(Foo<Map.Entry<Number, Boolean>, String> p) {
      
          ConcurrentHashMap.KeySetView<Number, Boolean> x = null;
          ConcurrentHashMap<Number, Boolean> y = x.getMap();
          y.<String>reduceEntries(19, p::apply, null); // works
      
          x.getMap().<String>reduceEntries(19, p::apply, null); // fails
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 15: Failed to find method 'apply(java.util.Map$Entry<java.lang.Object, java.lang.Object>)' for the type: Foo<java.util.Map$Entry<java.lang.Number, java.lang.Boolean>, java.lang.String> @ line 15, column 42.
         p().<String>reduceEntries(19, p::apply,
                                       ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Notes

      Tested against master

      Attachments

        Activity

          People

            Unassigned Unassigned
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: