Re: Surprising behavior casting BigInteger to int/long for constructor call
Sean Gilligan <[email protected]>
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <[email protected]> |
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 <[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 >> >> >>