[code-reflection] RFR: Fix the bug of pattern variable initialized with conversion
Mourad Abbay
mabbay at openjdk.org
Fri Dec 19 20:22:18 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.
-------------
Commit messages:
- Apply the fix
Changes: https://git.openjdk.org/babylon/pull/771/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=771&range=00
Stats: 13 lines in 1 file changed: 7 ins; 0 del; 6 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