Skip to content

fix: update Apply pattern match arity for auto-TCO strict field#751

Merged
stephenamar-db merged 1 commit intodatabricks:masterfrom
He-Pin:fix/scala213-auto-tco-patterns
Apr 11, 2026
Merged

fix: update Apply pattern match arity for auto-TCO strict field#751
stephenamar-db merged 1 commit intodatabricks:masterfrom
He-Pin:fix/scala213-auto-tco-patterns

Conversation

@He-Pin
Copy link
Copy Markdown
Contributor

@He-Pin He-Pin commented Apr 11, 2026

Motivation

The auto-TCO commit (ecdd0b6, PR #694) added a strict: Boolean field to Apply, Apply0, Apply1, Apply2, and Apply3 case classes. The hasSelfRefExpr pattern matches in Materializer were not updated, causing:

  1. Compilation failure on Scala 2.13.18: wrong number of arguments for pattern sjsonnet.Expr.Apply
  2. Runtime MatchError on Scala 3.3.7: The pattern match silently fell through to the wildcard case, causing incorrect materialization paths for lazy reverse arrays (lazy_reverse_correctness.jsonnet failure)

Modification

Added wildcard for the new strict field in all five Apply pattern matches in Materializer.hasSelfRefExpr:

  • Apply(_, v, args, _, _)Apply(_, v, args, _, _, _)
  • Apply0(_, v, _)Apply0(_, v, _, _)
  • Apply1(_, v, a1, _)Apply1(_, v, a1, _, _)
  • Apply2(_, v, a1, a2, _)Apply2(_, v, a1, a2, _, _)
  • Apply3(_, v, a1, a2, a3, _)Apply3(_, v, a1, a2, a3, _, _)

Result

  • Scala 2.13.18 compiles and all tests pass (including lazy_reverse_correctness.jsonnet)
  • Scala 3.3.7 all tests pass (no regressions)

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).
@He-Pin
Copy link
Copy Markdown
Contributor Author

He-Pin commented Apr 11, 2026

@stephenamar-db cc

@stephenamar-db stephenamar-db merged commit 1bf3b40 into databricks:master Apr 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants