[code-reflection] RFR: Fix the bug of pattern variable initialized with conversion [v2]
Mourad Abbay
mabbay at openjdk.org
Fri Dec 19 20:26:59 UTC 2025
> 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
-------------
Changes:
- all: https://git.openjdk.org/babylon/pull/771/files
- new: https://git.openjdk.org/babylon/pull/771/files/e1b8f736..171a5627
Webrevs:
- full: https://webrevs.openjdk.org/?repo=babylon&pr=771&range=01
- incr: https://webrevs.openjdk.org/?repo=babylon&pr=771&range=00-01
Stats: 35 lines in 1 file changed: 35 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/babylon/pull/771.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/771/head:pull/771
PR: https://git.openjdk.org/babylon/pull/771
More information about the babylon-dev
mailing list