Groovy
  1. Groovy
  2. GROOVY-3135

Incorrect array type created when calling vararg method

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.6
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Environment:
      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.

      1. 3135Patch.zip
        2 kB
        Roshan Dawrani

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            peter royal
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development