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

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

     [ https://issues.apache.org/jira/browse/GROOVY-9821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christopher Smith updated GROOVY-9821:
--------------------------------------
    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:

{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.

  was:
I have been unable to create a more minimal MCVE, but this is reproducable 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.


> 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
>            Priority: Minor
>
> 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)