RFR: 8328747: WrongMethodTypeException with pattern matching on switch on sealed classes [v2]

Vicente Romero vromero at openjdk.org
Wed Apr 3 20:37:10 UTC 2024


On Wed, 3 Apr 2024 15:00:25 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

>> This PR addresses the issue that the expected signature for `typeSwitch` is different when a release target refers to a version prior to JDK 23. The signature, due to JEP 455, needs to be more precise on the `selectorType` now that primitive type support is previewed.
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Append empty line

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 500:

> 498:             boolean primitiveSelector = seltype.isPrimitive();
> 499:             Name bootstrapName = enumSelector ? names.enumSwitch : names.typeSwitch;
> 500:             MethodSymbol bsm = rs.resolveInternalMethod(tree.pos(), env, syms.switchBootstrapsType,

side: variable `primitiveSelector` is not used and could be removed

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 503:

> 501:                     bootstrapName, staticArgTypes, List.nil());
> 502: 
> 503:             Type resolvedSelectorType = syms.objectType;

isn't this change assigning Object to `resolvedSelectorType` for more cases than before JEP455? not sure if there is a semantic change here

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18606#discussion_r1550418688
PR Review Comment: https://git.openjdk.org/jdk/pull/18606#discussion_r1550420697


More information about the compiler-dev mailing list