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

Incomplete generic type inference for list.property notation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.1
    • 2.3.11, 2.4.2
    • None
    • None

    Description

      The following code will not compile:

      class Account {
         String id
      }
      class GCAccount {
         List<Account> sfAccounts
      }
      class User {
         List<GCAccount> gcAccounts
      }
      
      @groovy.transform.CompileStatic
      void foo() {
      def accounts = (1..10).collect { new Account(id:"Id $it") }
      def user = new User(gcAccounts:[new GCAccount(sfAccounts:accounts[0..2]),new GCAccount(sfAccounts:accounts[3..4])])
      def ids = user.gcAccounts.sfAccounts.id.flatten()
      println ids
      }
      foo()
      

      The error is:

      No such property: id for class: java.util.List <java.util.List>
      

      indicating that the generic type inference is incomplete.

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: