Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0
-
None
Description
When adjusting NamedVariant to cater for its use (under the covers) for records, a few anomalies were introduced. The first is fixed in GROOVY-10497. This one covers a left over case for null.
For this method:
def x(int one, int two = 42) { "$one $two" }
Calling any of the following will fail with a MissingMethodException:
x(null) x(null, 3) x(3, null)
When NamedVariant is applied, e.g.
@groovy.transform.NamedVariant def m(int one, int two = 42) { "$one $two" }
Then all of the following succeed:
m(one:null) // 0 42 m(one:null, two:null) // 0 42 m(one:32, two:null) // 32 42 m(one:null, two:52) // 0 52
When null is encountered, we supply either the explicit or implicit default value. The purpose of this issue is to revert the behavior of this edge case to more traditional behavior, so the previous calls would all give a MissingMethodException.
Attachments
Issue Links
- is a clone of
-
GROOVY-10497 NamedVariant: default value overrides supplied value if it's falsy
- Closed