RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Oct 2 17:31:34 UTC 2023
On Mon, 2 Oct 2023 14:47:59 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:
>> This is the first draft of a patch for Primitive types in patterns, instanceof, and switch (Preview).
>>
>> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/instanceof-20230913/specs/instanceof-jls.html
>
> 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/code/Types.java line 5052:
> 5050:
> 5051: return (source.isPrimitive() && target.isPrimitive()) &&
> 5052: ((source.hasTag(BYTE) && !target.hasTag(CHAR) ||
Does this mean that `byte` -> `char` is not exact? Aren't both integral types, thus invalidating `widening from one integral type to another` ?
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4154:
> 4152: public void visitTypeTest(JCInstanceOf tree) {
> 4153: Type exprtype = attribExpr(tree.expr, env);
> 4154: if(!allowPrimitivePatterns) {
nit: space missing
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1342954914
PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1342958314
More information about the compiler-dev
mailing list