Fix module reflection when instrumentation is active (#1464)

This commit is contained in:
Jen Basch
2026-03-23 07:42:40 -07:00
committed by GitHub
parent 3f3271d3b1
commit a6db476c70
3 changed files with 24 additions and 4 deletions
@@ -0,0 +1,15 @@
import "pkl:reflect"
import "pkl:test"
class Foo {
bar: String(startsWith("a"))
}
// regression test for VmTyped.getImports()
// which walks module members that are imports and casts their bodies to ImportNode
// the catch activates instrumentation by failing a constraint check
// so that the reflected import member bodies are wrapper nodes instead of ImportNode directly
// the fix for this unwraps the wrapper before casting to ImportNode
foo =
let (_ = test.catchOrNull(() -> new Foo { bar = "baz" }.bar))
reflect.Module(module).imports
@@ -0,0 +1 @@
foo = Map("reflect", "pkl:reflect", "test", "pkl:test")