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 2023/01/03 18:59:00 UTC
[jira] [Updated] (GROOVY-10889) Casting of arguments in @NamedVariant method has no effect
[ https://issues.apache.org/jira/browse/GROOVY-10889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10889:
---------------------------------
Summary: Casting of arguments in @NamedVariant method has no effect (was: Casting of arguments in `@NamedVariant` method has no effect)
> Casting of arguments in @NamedVariant method has no effect
> ----------------------------------------------------------
>
> Key: GROOVY-10889
> URL: https://issues.apache.org/jira/browse/GROOVY-10889
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.6
> Reporter: Pavlo Shevchenko
> Priority: Minor
>
> {code:java}
> import groovy.transform.NamedVariant
> class Reproducer {
> @NamedVariant
> private static Tuple2<Integer, Set<String>> createSampleData(
> Integer left = 0,
> Set<String> right = [] as Set
> ) {
> Tuple2.tuple(left, right)
> }
> static void main(String[] args) {
> createSampleData(left: 1)
> }
> }
> {code}
> The default value of "right" argument (i.e. "[] as Set") is detected as "ArrayList" despite the explicit cast. This used to work in Groovy 3.x, and now fails with
> {code:java}
> Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static dev.pshevche.Reproducer.createSampleData() is applicable for argument types: (Integer, ArrayList) values: [1, []]{code}
> Replacing the "[] as Set" with "new HashSet<>()" resolves the issue.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)