expression type A is a subtype of pattern type B diagnostics
Archie Cobbs
archie.cobbs at gmail.com
Tue Apr 1 17:35:16 UTC 2025
Yeah, so the new feature was new enough to change its behavior, but the old
feature wasn't...
I guess you'd call that age before beauty :)
On Tue, Apr 1, 2025 at 12:23 PM Liam Miller-Cushon <cushon at google.com>
wrote:
> I wondered if that was it: arguably it would be good if `e instanceof Y`
> was also an error in this case, but that ship has sailed. There's tension
> between trying to use new features to fix mistakes of the past, and having
> a smooth onramp to new features, and I know that's been discussed in other
> contexts.
>
> The surprising part to me was that the error was introduced, and then
> removed as part of the implementation of record patterns.
>
> On Tue, Apr 1, 2025 at 10:04 AM Archie Cobbs <archie.cobbs at gmail.com>
> wrote:
>
>> On Tue, Apr 1, 2025 at 11:49 AM Liam Miller-Cushon <cushon at google.com>
>> wrote:
>>
>>> So all of this seems deliberate and working as intended, I was just
>>> curious what the rationale for the change was. Does anyone remember the
>>> history or have pointers to discussions about it on list?
>>>
>>
>> I don't know what the stated rationale was at the time, but the change
>> makes intuitive sense to me now: Why should "e instanceof Y x" generate an
>> error when "e instanceof Y" does not? That is to say: the correctness of
>> the type test itself, which is what the error is about, has nothing to do
>> with whether or not you happen to be declaring a new variable that captures
>> a successful outcome of that test.
>>
>> -Archie
>>
>> --
>> Archie L. Cobbs
>>
>
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20250401/081a01fe/attachment.htm>
More information about the compiler-dev
mailing list