From 724ca29cbb2c5890c9d6358ce3a0c99dd39353d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E=E9=B8=A3?= Date: Sun, 12 Apr 2026 03:41:27 +0800 Subject: [PATCH] fix: update Apply pattern match arity for auto-TCO strict field Motivation: The auto-TCO commit (ecdd0b6) added a `strict: Boolean` field to Apply, Apply0, Apply1, Apply2, and Apply3 case classes. The hasSelfRefExpr pattern matches in Materializer were not updated, causing compilation failure on Scala 2.13.18 and runtime MatchError on Scala 3.3.7 (caught by wildcard, leading to incorrect code paths for lazy reverse arrays). Modification: Added wildcard for the new `strict` field in all five Apply pattern matches in Materializer.hasSelfRefExpr. Result: Fixes Scala 2.13.18 compilation and the lazy_reverse_correctness test failure (which was caused by MatchError falling through to incorrect materialization path). --- sjsonnet/src/sjsonnet/Materializer.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sjsonnet/src/sjsonnet/Materializer.scala b/sjsonnet/src/sjsonnet/Materializer.scala index 2238f51b..bcf7f478 100644 --- a/sjsonnet/src/sjsonnet/Materializer.scala +++ b/sjsonnet/src/sjsonnet/Materializer.scala @@ -707,17 +707,17 @@ object Materializer extends Materializer { case Expr.Error(_, v) => hasSelfRefExpr(v, inNestedObj) // Apply variants - case Expr.Apply(_, v, args, _, _) => + case Expr.Apply(_, v, args, _, _, _) => hasSelfRefExpr(v, inNestedObj) || args.exists(a => hasSelfRefExpr(a, inNestedObj)) - case Expr.Apply0(_, v, _) => hasSelfRefExpr(v, inNestedObj) - case Expr.Apply1(_, v, a1, _) => + case Expr.Apply0(_, v, _, _) => hasSelfRefExpr(v, inNestedObj) + case Expr.Apply1(_, v, a1, _, _) => hasSelfRefExpr(v, inNestedObj) || hasSelfRefExpr(a1, inNestedObj) - case Expr.Apply2(_, v, a1, a2, _) => + case Expr.Apply2(_, v, a1, a2, _, _) => hasSelfRefExpr(v, inNestedObj) || hasSelfRefExpr(a1, inNestedObj) || hasSelfRefExpr( a2, inNestedObj ) - case Expr.Apply3(_, v, a1, a2, a3, _) => + case Expr.Apply3(_, v, a1, a2, a3, _, _) => hasSelfRefExpr(v, inNestedObj) || hasSelfRefExpr(a1, inNestedObj) || hasSelfRefExpr(a2, inNestedObj) || hasSelfRefExpr(a3, inNestedObj)