1 import jdk.incubator.code.CodeReflection;
 2 
 3 /*
 4  * @test
 5  * @modules jdk.incubator.code
 6  * @build PatternTest2
 7  * @build CodeReflectionTester
 8  * @run main CodeReflectionTester PatternTest2
 9  */
10 public class PatternTest2 {
11     record R<T extends Number> (T n) {}
12 
13     @IR("""
14             func @"f" (%0 : java.lang.Object)boolean -> {
15                 %1 : Var<java.lang.Object> = var %0 @"o";
16                 %2 : java.lang.Object = var.load %1;
17                 %3 : java.lang.Integer = constant @null;
18                 %4 : Var<java.lang.Integer> = var %3 @"i";
19                 %5 : boolean = pattern.match %2
20                     ()jdk.incubator.code.op.ExtendedOp$Pattern$Record<PatternTest2$R<#PatternTest2$R::T<java.lang.Number>>> -> {
21                         %6 : jdk.incubator.code.op.ExtendedOp$Pattern$Type<java.lang.Integer> = pattern.type @"i";
22                         %7 : jdk.incubator.code.op.ExtendedOp$Pattern$Record<PatternTest2$R<#PatternTest2$R::T<java.lang.Number>>> = pattern.record %6 @"(#PatternTest2$R::T<java.lang.Number> n)PatternTest2$R<#PatternTest2$R::T<java.lang.Number>>";
23                         yield %7;
24                     }
25                     (%8 : java.lang.Integer)void -> {
26                         var.store %4 %8;
27                         yield;
28                     };
29                 return %5;
30             };
31             """)
32     @CodeReflection
33     static boolean f(Object o) {
34         return o instanceof R(Integer i);
35     }
36 }