File tree Expand file tree Collapse file tree
main/java/org/pkl/core/runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -158,7 +158,8 @@ public int getRegularMemberCount() {
158158 }
159159
160160 private boolean isHiddenOrLocalProperty (Object key ) {
161- return key instanceof Identifier
162- && (key == Identifier .DEFAULT || ((Identifier ) key ).isLocalProp ());
161+ return key instanceof ObjectMember member && member .isLocal ()
162+ || key instanceof Identifier identifier
163+ && (key == Identifier .DEFAULT || identifier .isLocalProp ());
163164 }
164165}
Original file line number Diff line number Diff line change @@ -635,7 +635,7 @@ class EvaluatorTest {
635635 }
636636
637637 @Test
638- fun `nested pkl-binary rendiring produces correct results` () {
638+ fun `nested pkl-binary rendering produces correct results` () {
639639 val evaluator =
640640 with (EvaluatorBuilder .preconfigured()) {
641641 allowedResources.add(Pattern .compile(" b64:" ))
@@ -696,6 +696,48 @@ class EvaluatorTest {
696696 }
697697 }
698698
699+ @Test
700+ fun `objects with object locals are encoded correctly` () {
701+ val data =
702+ evaluator.evaluateOutputBytes(
703+ text(
704+ """
705+ import "pkl:pklbinary"
706+
707+ dynamic: Dynamic = new {
708+ local foo = new Test {}
709+ bar = foo
710+ }
711+ listing: Listing = new {
712+ local foo = new Test {}
713+ foo
714+ }
715+ mapping: Mapping = new {
716+ local foo = new Test {}
717+ ["bar"] = foo
718+ }
719+ `class`: MyClass = new {
720+ local foo = new Test {}
721+ bar = foo
722+ }
723+
724+ class MyClass {
725+ bar: Test
726+ }
727+
728+ class Test
729+
730+ output {
731+ renderer = new pklbinary.Renderer {}
732+ }
733+ """
734+ .trimIndent()
735+ )
736+ )
737+
738+ assertThatCode { PklBinaryDecoder .decode(data) }.doesNotThrowAnyException()
739+ }
740+
699741 @Test
700742 fun `power assertions work with test facts with unavailable source section` () {
701743 val evaluator =
You can’t perform that action at this time.
0 commit comments