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 2021/07/23 18:23:00 UTC
[jira] [Updated] (GROOVY-10179) STC: instanceof and for-in variable
type
[ https://issues.apache.org/jira/browse/GROOVY-10179?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10179:
---------------------------------
Summary: STC: instanceof and for-in variable type (was: STC: instanceof and for-in loop type)
> STC: instanceof and for-in variable type
> ----------------------------------------
>
> Key: GROOVY-10179
> URL: https://issues.apache.org/jira/browse/GROOVY-10179
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.14, 3.0.8, 4.0.0-alpha-3
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
>
> Variation of GROOVY-6240. Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test(args) {
> if (args instanceof Map) {
> for (e in args) {
> print "$e.key $e.value" // STC errors: No such property "key/value" for Object
> }
> }
> }
> test(a:1,b:2,c:3.14)
> {code}
> When the extra layer of the instanceof check is added, STC does not use Map type when inferring type of for-in variable "e".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)