[
https://issues.apache.org/jira/browse/GROOVY-6309?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-6309.
-----------------------------
> 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.20.1#820001)