[ https://issues.apache.org/jira/browse/GROOVY-10953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17696698#comment-17696698 ]
Paul King commented on GROOVY-10953: ------------------------------------ [~emilles] I cloned the issue to cater for such cases. We can't do it in general but there are cases we can check, e.g. where from and to for the range are constant expressions. I'd have to check whether we have any existing logic for enums, not sure if {{transformInlineConstants}} can be repurposed or we have something else already. I'd like to allow multi-assignment with STC for any list or array typed RHS (with the normal dynamic "null" behavior in place) but it needs more thought. Perhaps we should only allow range expressions where we can do the size checks in the meantime. > Extend multi-assignment type checking to Range expressions > ---------------------------------------------------------- > > Key: GROOVY-10953 > URL: https://issues.apache.org/jira/browse/GROOVY-10953 > Project: Groovy > Issue Type: Improvement > Reporter: Paul King > Assignee: Paul King > Priority: Major > Fix For: 5.0.0-alpha-1 > > > The following code runs fine without {{TypeChecked}} but fails in static > checking mode. > {code} > @groovy.transform.TypeChecked > def method() { > def (x, y, z) = 1..3 > assert "$x $y $z" == '1 2 3' > } > method() > {code} > The error is: > {noformat} > [Static type checking] - Multiple assignments without list or tuple on the > right-hand side are unsupported in static type checking mode > {noformat} > The workaround is to replace the range on the RHS of the multi-assignment > with a list: > {code} > def (x, y, z) = [1, 2, 3] > {code} > But since we know the range expression, we can do further checking. -- This message was sent by Atlassian Jira (v8.20.10#820010)