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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Eric Milles (Jira)

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

Paul King edited comment on GROOVY-9821 at 11/20/20, 12:57 PM:
---------------------------------------------------------------

Proposed PR merged. Thanks all! Just in master for now.

Breaks in 3_0_X with errors like:
{noformat}
groovy.transform.stc.ArraysAndCollectionsSTCTest > testSetSpread FAILED
 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
 TestScripttestSetSpread51.groovy: 6: [Static type checking] - Cannot find matching method java.lang.Object#contains(java.lang.String). Please check if the declared type is correct and if the method exists.
 @ line 6, column 20.
 assert res[1].contains('ghi')
        ^
{noformat}
And I haven't had time to track down whatever dependent commits it relies on just yet.


was (Author: paulk):
Proposed PR merged. Thanks all! Just in master for now.

Breaks in 3_0_X with errors like:
{noformat}
groovy.transform.stc.ArraysAndCollectionsSTCTest > testSetSpread FAILED
 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
 TestScripttestSetSpread51.groovy: 6: [Static type checking] - Cannot find matching method java.lang.Object#contains(java.lang.String). Please check if the declared type is correct and if the method exists.
 @ line 6, column 20.
 assert res[1].contains('ghi')
           ^
{noformat}
And I haven't had time to track down whatever dependent commits it relies on just yet.

> 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
>             Fix For: 4.0.0-alpha-2
>
>          Time Spent: 20m
>  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)