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

each parameter type not correctly inferenced

    XMLWordPrintableJSON

Details

    Description

      Consider this Java class:

      package test51;
      
      import java.util.List;
      
      public class Foo {
          public List<Object[]> bar() { return null; }
      }

       and this Groovy class:

      package test51
      
      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Test51 {
          protected void foo() {
              List<Object[]> foo = new Foo().bar()
              foo.each { row ->
                  def o = row[0]
              }
          }
          
          List bar() {
          }
      }

      This produces a compiler error because row is resolved as Object rather than Object[].

      A workaround is to declare row as Object[] row in the closure parameter list.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              mauromol Mauro Molinari
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m