Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10502

NamedVariant: improve consistency of default value treatment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0
    • 3.0.10, 4.0.1
    • 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

          Activity

            People

              paulk Paul King
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m