RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v42]

Aggelos Biboudis abimpoudis at openjdk.org
Wed Jan 24 14:59:01 UTC 2024


On Wed, 24 Jan 2024 12:22:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Set previewEnabled properly in SwitchBootstraps
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1924:
> 
>> 1922:     }
>> 1923:     // where
>> 1924:     static final Set<TypeTag> nonIntegralPrimitiveTypes = Set.of(
> 
> This feels like a method on TypeTag?

Addressed in https://github.com/openjdk/jdk/pull/15638/commits/9b7fb7fcdd2b393425267313622970ba709c645e

> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4147:
> 
>> 4145:         }
>> 4146:         if (clazztype.isPrimitive()) {
>> 4147:             preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS);
> 
> So, if I have a primitive instanceof, I get two preview warnings, one for the expression, and one for the pattern type? Shouldn't one be enough?

Meaning the `compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)` error due to the two `if (clazztype.isPrimitive()) { preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS);` ifs? Isn't it better to keep both, for better error reporting regarding the position? (i.e., which position do we report?)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465034738
PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465033188


More information about the core-libs-dev mailing list