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/06/08 22:14:00 UTC

[jira] [Resolved] (GROOVY-6309) Type inference for tuple assignment does not work (static compilation)

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

Eric Milles resolved GROOVY-6309.
---------------------------------
    Resolution: Fixed

If "List<String>" is replaced by "Tuple2<String,String>" in the example, this style is supported in Groovy 4.

> Type inference for tuple assignment does not work (static compilation)
> ----------------------------------------------------------------------
>
>                 Key: GROOVY-6309
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6309
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 2.1.5
>            Reporter: Peter Ledbrook
>            Priority: Major
>
> It is my expectation that this example should compile:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> void doSomething() {
>     def (version, path) = getVersionAndTargetPath()
>     testMethod version, path
> }
> List<String> getVersionAndTargetPath() {
>     return ["1.0", "/var/tmp"]
> }
> int testMethod(String arg1, String arg2) {
>     return 1
> }
> {code}
> But I get a compilation error:
> {noformat}
> [Static type checking] - Multiple assignments without list expressions on the right hand side are unsupported in static type checking mode
>  at line: 5, column: 27
> [Static type checking] - Cannot find matching method ConsoleScript3#testMethod(java.lang.Object, java.lang.Object). Please check if the declared type is right and if the method exists.
>  at line: 6, column: 5
> {noformat}
> Even if I declare {{version}} and {{path}} to be {{String}}, the first of the compiler errors still remains.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)