Skip to content

Conversation

@jevanlingen
Copy link
Contributor

@jevanlingen jevanlingen commented Aug 20, 2025

What's changed?

Top-level Kotlin functions now correctly have their declaring type set.

What's your motivation?

Top-level functions in Kotlin do not belong to a class in the FIR frontend, although the backend generates a synthetic JVM class. The previous logic does produce incorrect declaringType values when the top-level function was located in a different file than the method invocation. By handling the case where a function has no enclosing class, we can assign a correct synthetic declaring type based on the file.

This ensures accurate representation of top-level functions in the parser, which is needed for:

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

github-actions[bot]

This comment was marked as outdated.

@jevanlingen jevanlingen force-pushed the type-information-top-level-method-invocations branch from e8c58c6 to 54553f5 Compare August 21, 2025 06:30
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@jevanlingen jevanlingen force-pushed the type-information-top-level-method-invocations branch from 54553f5 to 1636d04 Compare August 21, 2025 06:30
@openrewrite openrewrite deleted a comment from github-actions bot Aug 21, 2025
@jevanlingen jevanlingen marked this pull request as ready for review August 21, 2025 07:43
@jevanlingen jevanlingen moved this from In Progress to Ready to Review in OpenRewrite Aug 21, 2025
…st.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@jevanlingen jevanlingen force-pushed the type-information-top-level-method-invocations branch from 0bba682 to 53e673a Compare August 21, 2025 07:51
@jevanlingen jevanlingen changed the title Add declaring type information for Kotlin top level functions Add declaring type information for Kotlin top-level functions Aug 21, 2025
@jevanlingen jevanlingen changed the title Add declaring type information for Kotlin top-level functions Improve declaring type information for Kotlin top-level functions Aug 21, 2025
@jevanlingen jevanlingen force-pushed the type-information-top-level-method-invocations branch from 2863991 to 57eda9b Compare August 25, 2025 08:17
@jevanlingen jevanlingen merged commit 425c565 into main Aug 26, 2025
2 checks passed
@jevanlingen jevanlingen deleted the type-information-top-level-method-invocations branch August 26, 2025 07:23
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants