[code-reflection] RFR: Fix the bug of pattern variable initialized with conversion [v2]
Paul Sandoz
psandoz at openjdk.org
Fri Dec 19 21:59:50 UTC 2025
On Fri, 19 Dec 2025 20:26:59 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> Generating code model for code such as:
>> ```@Reflect
>> void m(int i) {
>> if (i instanceof byte b) {
>>
>> }
>> }
>> ```
>> was causing the below error in the compiler:
>>
>> java.lang.IllegalStateException: Operand of operation jdk.incubator.code.dialect.core.CoreOp$VarOp at 503d687a is not defined in tree: %result at 482bce4f
>> at jdk.incubator.code/jdk.incubator.code.Block.bindOp(Block.java:764)
>> at jdk.incubator.code/jdk.incubator.code.Block.insertOp(Block.java:743)
>> at jdk.incubator.code/jdk.incubator.code.Block$Builder.op(Block.java:697)
>> at jdk.incubator.code/jdk.incubator.code.internal.ReflectMethods$BodyScanner.scanPattern(ReflectMethods.java:1342)
>> ...
>>
>> The cause is that we were adding the op that perform the conversion to the block of the IfOp first body, making the value unreachable to the VarOp of the pattern variable.
>> The fix is from @PaulSandoz.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
Marked as reviewed by psandoz (Lead).
-------------
PR Review: https://git.openjdk.org/babylon/pull/771#pullrequestreview-3600259248
More information about the babylon-dev
mailing list