Skip to content

Fix StackOverflowError in Kotlin parser for deeply nested binary expressions#7083

Draft
zieka wants to merge 1 commit intomainfrom
fix/ci-error
Draft

Fix StackOverflowError in Kotlin parser for deeply nested binary expressions#7083
zieka wants to merge 1 commit intomainfrom
fix/ci-error

Conversation

@zieka
Copy link
Member

@zieka zieka commented Mar 20, 2026

Summary

  • Converts recursive left-child traversal in KotlinTreeParserVisitor.visitBinaryExpression() to an iterative approach
  • Collects the left spine of nested KtBinaryExpression nodes into a list and processes them bottom-up, preventing StackOverflowError on deeply nested expressions (e.g. 2000+ string concatenations)
  • Updates mapFunctionCall() to accept a pre-computed left expression instead of re-visiting the left child

Fixes the CI failure: https://github.com/openrewrite/rewrite/actions/runs/23356509331/job/67948579231

Test plan

  • BinaryTest.deeplyNestedStringConcatenation() now passes (was failing with StackOverflowError)
  • Full rewrite-kotlin test suite passes (1173 tests, 0 failures)

…essions

Convert recursive left-child traversal in visitBinaryExpression to an
iterative approach, collecting the left spine of nested KtBinaryExpression
nodes and processing them bottom-up. This prevents stack overflow when
parsing deeply nested expressions (e.g. 2000+ string concatenations).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant