[jdk19] RFR: 8289196: Patttern domination not working property for record patterns [v2]

Jan Lahoda jlahoda at openjdk.org
Fri Jul 1 18:13:40 UTC 2022


On Fri, 1 Jul 2022 16:28:34 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Adding test, as suggested.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 4423:
> 
>> 4421:             }
>> 4422:             if (existingPatternType.isPrimitive()) {
>> 4423:                 if (!types.isSameType(existingPatternType, currentPatternType)) {
> 
> note: shouldn't we return true if both have the same type? I mean this method seems to returns the right thing in that case but it is doing some extra analysis that doesn't seem to be necessary IMO

We could, but I am not sure if that's not "too clever". Returning `true` when the type is same is based on the fact that only binding patterns (type test patterns) can be of primitive types, so the tests below will always return `true`. I can do that if strongly preferred, but I somewhat like the separation of concerns, where we verify the types here, and then the structure is checked below, regardless of the pattern's type.

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

PR: https://git.openjdk.org/jdk19/pull/84


More information about the compiler-dev mailing list