Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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
-
Number of attachments :
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.
Activity
Guillaume Laforge
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.5.8 [ 14630 ] | |
| Fix Version/s | 1.6-rc-1 [ 14009 ] | |
| Fix Version/s | 1.7-beta-1 [ 14014 ] |
Roshan Dawrani
made changes -
| Attachment | 3135Patch.zip [ 38009 ] |
blackdrag blackdrag
made changes -
| Assignee | Roshan Dawrani [ roshandawrani ] |
Roshan Dawrani
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Hi,
Attaching patches for the affected groovy versions and a test case.
The fix is basically to make coercing of double-type arguments consistent between DoubleCachedClass and ArrayCachedClass.
DoubleCachedClass allows all subclasses of java.lang.Number to be coerced into double type but ArrayCachedClass for varargs of double type allowed coercing only from float/double/BigDecimal types and not from other Number sub-classes and failed with "argument type mismatch" error.
rgds,
Roshan