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

Paul King <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAMbkE7QvS-VGdOsX8++89PiXZ4f-vZaXF0qgwjpevu_iagFb=g@mail.gmail.com>
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 <[email protected]> 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
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.