Skip to content

Conversation

@raulraja
Copy link
Member

@raulraja raulraja commented Sep 8, 2025

This pull request resolves a critical UnboundSymbolsError in the Arrow Reflection Kotlin compiler plugin by ensuring correct symbol binding during IR generation, and documents the investigation and solution in a new debugging report. The main fix preserves the original FIR symbol instance rather than creating a new one, which maintains the required binding chain between FIR and IR phases. Additional improvements include better handling of CallableId mismatches for transformation tests, regeneration of test expectation files, and code cleanups. One transformation test still fails due to stricter IR validation, but this is identified as a test framework artifact rather than a production issue.

Symbol Binding and IR Generation Improvements

  • Modified FirMetaCodegenExtension.kt to preserve the original function symbol in generated functions, preventing UnboundSymbolsError and ensuring FIR-to-IR symbol binding is maintained.
  • Added logic to patch function CallableIds when necessary for transformation tests, using reflection to update the symbol's CallableId only if there is a mismatch, without breaking symbol binding.

Documentation and Debugging

  • Added a comprehensive debugging report (DEBUGGING_REPORT.md) detailing the investigation, root cause, attempted solutions, technical analysis, and recommendations related to the symbol binding issue.

References:
[1] [2] [3] [4] [5] [6] [7] [8]

@raulraja raulraja requested a review from bloderxd September 8, 2025 16:49
@what-the-diff
Copy link

what-the-diff bot commented Sep 8, 2025

PR Summary

  • Comprehensive Debugging Report Added

    A detailed debugging report titled DEBUGGING_REPORT.md has been included. This report discusses how an error in the Kotlin compiler plugin was resolved. It includes an overview, a detailed problem description, investigation timelines, and future development suggestions.

  • FirMetaCodegenExtension.kt Modifications

    Necessary changes were made to this file.

    • A problematic symbol creation that was breaking chains was removed.
    • The updateCallableId function was introduced for updating CallableId via reflection without disrupting the symbol binding.
    • To handle mismatches in CallableId without breaking symbol binding, patchFunctionCallableIds was added.
  • TemplateCompiler.kt Adjustments

    Some housekeeping was done wherein commented codes relating to inaccessible implicit receivers and local scopes were removed for a cleaner look.

  • MetaContext.kt Updates

    The import lines were adjusted for a clear and consistent look. By organizing and including necessary FIR symbols, understanding the structure and dependencies has been made easier.

  • Test Expectation Files Tweaked

    The test cases were updated for alignment with the new CallableId handling and to bring consistency in all tests. In specific tests like product_test.fir.txt and increment_test.fir.txt, changes were made to match the new implementation details.

  • Test File (increment_test.kt) Updated

    Changes were made in the package name and way the sample class is instantiated. The required integration with the @Product annotation has been reflected.

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