qownz commented on code in PR #3295:
URL: https://github.com/apache/groovy/pull/3295#discussion_r4556029412
##########
src/test/groovy/org/codehaus/groovy/transform/NamedVariantTransformTest.groovy:
##########
@@ -326,6 +326,24 @@ final class NamedVariantTransformTest {
'''
}
+ @Test // GROOVY-10498
+ void testFalsyPositionalArgumentOverridesDefaultValue() {
+ assertScript shell, '''
+ @ToString(includeNames=true)
+ class Color {
+ int r, g, b
+ }
+
+ @NamedVariant
+ String m(@NamedDelegate Color color, Number alpha = 4.5) {
+ return "$color $alpha"
+ }
+
+ assert m(r:1, g:2, b:3, 0.0) == 'Color(r:1, g:2, b:3) 0.0'
+ assert m(r:1, g:2, b:3, 9) == 'Color(r:1, g:2, b:3) 9'
Review Comment:
`m(r:1, g:2, b:3)` fails on master too: the generated `Map` variant gets no
default-argument overload (TODO in `createMapVariant`). Left the assertion out.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]