RFR: 8367530: The exhaustiveness errors could be improved [v8]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Nov 14 14:17:23 UTC 2025


On Fri, 14 Nov 2025 14:11:39 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fixing trailing whitespaces.
>
> test/langtools/tools/javac/patterns/ExhaustivenessConvenientErrors.java line 352:
> 
>> 350:                """,
>> 351:                "test.Test.Root(test.Test.R2 _, test.Test.R2(test.Test.Base _, test.Test.R2 _), test.Test.R2(test.Test.R2 _, test.Test.Base _))");
>> 352:                //ideally, the result would be as follow, but it is difficult to split Base on two distinct places:
> 
> With recursion it should be possible -- but I guess the problem becomes, when do you stop?
> 
> e.g.
> `{ Base } -> { R1, R2 } -> { R1, R2(Base, Base) } -> ...`

Perhaps an idea here (not sure how crazy -- possibly a lot) would be to run an analysis on the original patterns as defined in the source code, and determine the _max depth_, and then expand "up to that depth".

So, in the above case, you would know that when you get to `{R1, R2}`, it's "good enough" for the level of depth that is present in the code.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27256#discussion_r2527664757


More information about the compiler-dev mailing list