Skip to content

fix: prevent StackOverflow on self-referencing types and remap lambda receiver#24

Merged
wilmveel merged 1 commit intomainfrom
fix/serializable-target-support
Mar 27, 2026
Merged

fix: prevent StackOverflow on self-referencing types and remap lambda receiver#24
wilmveel merged 1 commit intomainfrom
fix/serializable-target-support

Conversation

@wilmveel
Copy link
Copy Markdown
Contributor

Summary

  • Add cycle detection (visited set) to resolveConstructorFields and resolvePropertyFields in the FIR checker to prevent StackOverflowError when types reference themselves (e.g. data class Node(val parent: Node?))
  • Remap the TO extension receiver ($this$mapper) in the IR visitor to prevent dangling IR references when nested lambdas (e.g. .map {}) implicitly capture it
  • Add tests for self-referencing types, nested lambdas in mapper blocks, and value class auto-mapping in DSL blocks

Test plan

  • shouldCompile_selfReferencingType — verifies Category(parent: Category?) no longer causes StackOverflow
  • shouldCompile_nestedLambdaInMapperBlock — verifies .map { tag -> tag.uppercase() } inside mapper lambda compiles and runs correctly
  • shouldCompile_valueClassAutoMapInDslBlock — verifies value class unwrapping works with explicit DSL mappings
  • shouldCompile_valueClassAutoMapInDslBlockWithSerializable — same with @Serializable target
  • All existing tests pass

🤖 Generated with Claude Code

…mapper in nested lambdas

Add cycle detection to resolveConstructorFields and resolvePropertyFields in
the FIR checker to prevent infinite recursion with self-referencing types.
Remap the TO extension receiver ($this$mapper) in the IR visitor to avoid
dangling references when nested lambdas capture it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wilmveel wilmveel merged commit 8c3445b into main Mar 27, 2026
1 check 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.

1 participant