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

List literal type inference does not take its context into account

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.4
    • Fix Version/s: None
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      bug.groovy
      def methodAcceptingListOfObjects(List<Object> lo) {}
      
      @groovy.transform.CompileStatic
      def usage() {
          methodAcceptingListOfObjects([1, 2, 3]) 
      }
      

      Compilation fails with

      [Static type checking] - Cannot call #methodAcceptingListOfObjects(java.util.List <java.lang.Object>) with arguments [java.util.List <java.lang.Integer>]
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              daniilo Daniil Ovchinnikov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: