RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jan 24 12:25:34 UTC 2024


On Wed, 24 Jan 2024 11:53:52 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

>> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview).
>> 
>> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/
>
> 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/code/Types.java line 5046:

> 5044: 
> 5045:         if (target.isPrimitive()) {
> 5046:             return (source.isReference() && isSubtype(source, target)) ||

I'm a bit confused here - in here we have:
* `target.isPrimitive()`
* `source.isReference()`

So, isn't it the case that `isSubtype(source, target)` is always false?

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?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464835145
PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464836721


More information about the core-libs-dev mailing list