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

Incorrect array type created when calling vararg method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.6
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • None
    • None
    • using groovy via gmaven-runtime-default 1.0-rc-3

    Description

      I have a constructor:

      Foo( String foo, long bar, double... values )
      

      in groovy, i am calling it with a String, a Long, and an Integer.

      ParameterTypes.fitToVarArgs correctly determines that the array is a Double.

      however, when MetaClassHelper.makeArray is called, it does:

              Class baseClass = secondary;
              if (obj != null) {
                  baseClass = obj.getClass();
              }
      

      which overrides the Double.class that is secondary, with Integer.class from the incoming value.

      The constructor invocation then fails since the correct type was not passed.

      Attachments

        1. 3135Patch.zip
          2 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            proyal Peter A Royal Jr.
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: