expression type A is a subtype of pattern type B diagnostics

David Alayachew davidalayachew at gmail.com
Tue Apr 1 22:30:37 UTC 2025


Was there any official announcement on this information? I bumped my head
into this wall many times, and I just walked out of it confused the more I
looked at it. I even made a post on both StackOverflow and the Amber Dev
mailing list, and walked away with answers that made sense locally, but
less so globally.

I am under the assumption that this is all changing over time, so maybe
that is what it is. Maybe the final result is fully one way or another.

On Tue, Apr 1, 2025, 1:35 PM Archie Cobbs <archie.cobbs at gmail.com> wrote:

> 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/47eda86a/attachment-0001.htm>


More information about the compiler-dev mailing list