[code-reflection] RFR: 8337162: Support primitives in patterns [v4]
Paul Sandoz
psandoz at openjdk.org
Fri Oct 4 16:18:50 UTC 2024
On Fri, 4 Oct 2024 03:02:40 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> Support primitives in patterns
>
> Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision:
>
> - Rename test file
> - Remove unnecessary import
test/jdk/java/lang/reflect/code/TestPrimitiveTypePatterns.java line 51:
> 49: // builds the model of:
> 50: // static boolean f(sourceType a) { return a instanceof targetType _; }
> 51: return func("f", functionType(JavaType.BOOLEAN, sourceType)).body(fblock -> {
A different approach to explicitly building the model is to reflect on code in Java method and transform it. The compiler already knows how to build models. Might be a good test case for transforming. Perhaps consider as a follow up PR?
test/jdk/java/lang/reflect/code/TestPrimitiveTypePatterns.java line 75:
> 73:
> 74: static Object defaultValue(JavaType t) {
> 75: if (List.of(PrimitiveType.BYTE, PrimitiveType.SHORT, PrimitiveType.CHAR, PrimitiveType.INT).contains(t)) {
You can use a pattern switch?
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/246#discussion_r1787941905
PR Review Comment: https://git.openjdk.org/babylon/pull/246#discussion_r1787942780
More information about the babylon-dev
mailing list