You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Sean Gilligan <se...@msgilligan.com> on 2022/02/05 22:30:18 UTC

Re: Surprising behavior casting BigInteger to int/long for constructor call

Should I create an issue?

-- Sean


On 1/20/22 6:09 AM, Paul King wrote:
> That does look a little weird, I'll have to delve deeper to understand
> if there is a good reason.
> As well as long, the same behavior is observed for short and byte (all
> I checked) and also for 2.5.15.
>
> Cheers, Paul.
>
> On Thu, Jan 20, 2022 at 11:54 AM Sean Gilligan <se...@msgilligan.com> wrote:
>> When I try the following code (on either Groovy 3.0.9 or Groovy 4.0.0-rc-2)
>>
>> class I {
>>       long v;
>>
>>       I(int i) {
>>           v = i;
>>       }
>> }
>>
>> class L {
>>       long v;
>>
>>       L(long l) {
>>           v = l;
>>       }
>> }
>>
>> def a = new I(1G)
>> def b = new L(1G)
>>
>> I get `Could not find matching constructor for: L(BigInteger)` when
>> trying to construct an `L`.  The `I` is constructed without error.
>>
>> Am I missing something or is this a bug?
>>
>> -- Sean
>>
>>
>>