Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postpone static field's companion resolution #251

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

fzhinkin
Copy link
Collaborator

@fzhinkin fzhinkin commented Jul 8, 2024

#245 fixed the way const vars from companion objects are handled. Unfortunately, the solution interferes with how any other static final fields are processed.

This PR postpones companion class resolution until it's known that a field corresponds to a property declared in a companion object.

Fixes #250

@fzhinkin
Copy link
Collaborator Author

fzhinkin commented Jul 8, 2024

@martinbonnin PTAL

Comment on lines 144 to 150
/*
* In certain cases (like with enum entries), the fact a field is both static and final does not
* imply it belongs to a companion object.
* We don't update field's `companionClass` until we're 100% sure the field was
* actually moved from the companion.
*/
companionClass = companionClassCandidate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about not updating companionClass at all here? Looks like CompanionFieldBinarySignature is only to be used for the actual field referencing the companion?
The bug is me copy/pasting the code from the other branch without realising there would be a side effect at the end of the function :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it seems reasonable to include companionClass so its visibility can be taken into account. But this part seems to be totally broken.

I'll remove the companionClass update and open a separate issue on proper const val handling.

The bug is me copy/pasting the code from the other branch without realising there would be a side effect at the end of the function :/

No worries, it's all about the way JVM ABI is built and filtered (to be more precise, how complicated it became at some point) in conjunction with the test coverage not being full.

@martinbonnin
Copy link
Contributor

LGTM thanks a lot for fixing this 🙏

@fzhinkin fzhinkin merged commit e91f7ac into develop Jul 9, 2024
3 checks passed
@fzhinkin fzhinkin deleted the 250-fix-static-fields-handling branch July 9, 2024 07:11
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