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

AIC via array-based (variadic) constructor null and array arguments

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.8
    • None

    Description

      Follow up from GROOVY-7370. Consider the following:

      class C {
        C(String... args) {
          strings = args
        }
        public String[] strings
      }
      def x = new C(null) { }
      assert x.strings == null
      def y = new String[0]
      def z = new C( y ) { }
      assert z.strings.length == 0
      

      7370 handles no arguments for array and more than one. Passing null is supposed to set the array to null, not pass an array with one null element. Passing an array through an untyped variable is also a problem.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: