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

STC overconstraints lambda's parameter types when expecting a SAM that involves wildcards

    XMLWordPrintableJSON

Details

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

    Description

      I have the following program

      class Test {
        void test() {
          m((Integer x, Integer y) -> 1);
        }
      
        void m(java.util.Comparator<? extends Object> x) {}
      }
      

      Actual behavior

      test.groovy: 3: [Static type checking] - Expected type java.lang.Object for lambda parameter: x
       @ line 3, column 8.
             m((Integer x, Integer y) -> 1);
                ^
      
      test.groovy: 3: [Static type checking] - Expected type java.lang.Object for lambda parameter: y
       @ line 3, column 19.
             m((Integer x, Integer y) -> 1);
                           ^
      
      2 errors
      

      Expected behaviour

      Compile successfully

      Tested against master (commit: 1d9f35a448a2a731499534841ffe64150e80744c)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: