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

STC: spread-safe and list property access error for CollType<? extends ItemType>

    XMLWordPrintableJSON

Details

    Description

      I have been unable to create a more minimal MCVE, but this is reproducible at will using the Spring Security libraries.

      The following method definition:

      def authorities(Authentication auth) {
          auth.authorities*.authority
      }
      

      produces an error

      No such property: authority for class: java.util.Collection <? extends org.springframework.security.core.GrantedAuthority>
      

      It should be attempting to spread the property access onto the collection's element type, not the collection itself. Using *.getAuthority() works as expected. I could not replicate with an inline Groovy test case; the resolution works, but invoking against the Authentication class reliably produces the error. The error occurs in both @CompileStatic and @TypeChecked.

      Removing static type checking makes Eclipse correctly display the interface-based property.

      Attachments

        Activity

          People

            emilles Eric Milles
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 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 - 1h
                1h