RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v3]
Aggelos Biboudis
abimpoudis at openjdk.org
Thu Oct 5 08:21:04 UTC 2023
On Tue, 3 Oct 2023 08:54:57 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>>
>> - Merge branch 'master' into primitive-patterns
>> - Implement type pairs to exactnessMethod name
>> - Apply suggestions from code review
>>
>> Co-authored-by: Raffaello Giulietti <raffaello.giulietti at oracle.com>
>> - 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview)
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 2929:
>
>> 2927: // This branch covers true unconditionality for the underlying type as well.
>> 2928: if (types.checkUnconditionallyExact(tree.expr.type, tree.pattern.type) &&
>> 2929: !(tree.expr.type.isReference() && types.isExactPrimitiveWidening(types.unboxedType(tree.expr.type), tree.pattern.type))) {
>
> Not super sure I get this line: if the expression type is unconditionally exact for the pattern type, shouldn't the test be always `true` ? What is the role of the extra guard after the `&&` ? Also, doesn't unconditionally exact implies that there is convertibility?
Agree to all. Convertibility was covered.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1346991986
More information about the compiler-dev
mailing list