On Wed, 11 Oct 2023 15:43:19 GMT, Aggelos Biboudis <abimpou...@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/jep443-20231010/specs/instanceof-jls.html
>
> Aggelos Biboudis has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fix duplicate method name and add a new test in 
> PrimitivePatternsSwitchErrors

src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 366:

> 364:             (selectorType.equals(int.class) && 
> targetType.equals(Integer.class)))
> 365:             return true;
> 366:         else if (selectorType.equals(targetType) || 
> (selectorType.equals(byte.class) && !targetType.equals(char.class)  ||

this code reminds me of some tricks we did to simplify similar code in the 
past, see `com.sun.tools.javac.code.TypeTag` and related:  
`com.sun.tools.javac.code.TypeTag.NumericClasses` and method 
`com.sun.tools.javac.code.TypeTag::isSubRangeOf` and how it is used to 
determine if a numerical type is subtype of another numerical type. These 
tricks could be reused here, but up to you. I could also be done in a future 
refactoring.

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

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

Reply via email to