Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
4.0.6
-
None
Description
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) } }
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
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, []]
Replacing the "[] as Set" with "new HashSet<>()" resolves the issue.
Attachments
Issue Links
- is related to
-
GROOVY-10561 @NamedVariant self referential default values are not correctly resolved
- Closed
- relates to
-
GROOVY-11325 @NamedVariant self referential default values are not correctly resolved when calculations are involved
- Closed