You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/11/19 21:50:00 UTC

[jira] [Commented] (GROOVY-9821) STC doesn't recognize interface-based properties

    [ https://issues.apache.org/jira/browse/GROOVY-9821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17235762#comment-17235762 ] 

Eric Milles commented on GROOVY-9821:
-------------------------------------

The problem was the {{Collection<? extends GrantedAuthority>}} return type.  https://github.com/apache/groovy/pull/1427

> STC doesn't recognize interface-based properties
> ------------------------------------------------
>
>                 Key: GROOVY-9821
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9821
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 3.0.6
>            Reporter: Christopher Smith
>            Assignee: Eric Milles
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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:
> {code:groovy}
> def authorities(Authentication auth) {
>     auth.authorities*.authority
> }
> {code}
> produces an error
> {code}
> No such property: authority for class: java.util.Collection <? extends org.springframework.security.core.GrantedAuthority>
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)