[
https://issues.apache.org/jira/browse/GROOVY-5700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17583014#comment-17583014
]
Eric Milles commented on GROOVY-5700:
-------------------------------------
https://github.com/apache/groovy/commit/0914362c1be5c9789d28417dd748496570a7b34a
> STC: different behavior w/ map subscript and property access when using elvis
> -----------------------------------------------------------------------------
>
> Key: GROOVY-5700
> URL: https://issues.apache.org/jira/browse/GROOVY-5700
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 2.0.2
> Reporter: Guillaume Sauthier
> Assignee: Cédric Champeau
> Priority: Major
> Fix For: 2.0.4
>
>
> There's a difference in behavior with static type checking between property
> and subscript access to map elements.
> {code}
> @groovy.transform.TypeChecked
> class Test {
> static void test() {
> def m = [retries: 10]
> // passes
> int r1 = m['retries'] ?: 1
> // fails
> int r2 = m.retries ?: 1
> }
> }
> Test.test()
> {code}
> Fails with:
> {code}
> [Static type checking] - Cannot assign value of type java.lang.Object to
> variable of type int
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)