On Fri, 8 May 2026 17:54:12 GMT, Dan Smith <[email protected]> wrote:
>> An abstract value class can have identity and value subclasses.
>>
>>
>> abstract value class Number { ... }
>> value class Integer extends Number { ... }
>> class BigInteger extends Number { ... }
>>
>>
>> I'm asking what happens when you try to get `this` from a constructor of
>> `Number`: do you check whether `this` is a value object (an Integer, not a
>> BigInteger), or do you apply the special-case logic to _all_ values of
>> `this`, whether they are Integers or BigIntegers?
>
> (I'm guessing a "snapshot" is an operation that only makes sense for value
> objects, so you would not do it for the BigInteger. But I'm not sure.)
Got it, thank you for checking!
> do you check whether this is a value object (an Integer, not a BigInteger),
> or do you apply the special-case logic to all values of this, whether they
> are Integers or BigIntegers?
We check whether this is a value object and do not care about identity objects
like BigIntegers.
> I'm guessing a "snapshot" is an operation that only makes sense for value
> objects, so you would not do it for the BigInteger.
Yes, exactly.
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/2412#discussion_r3210497450