Skip to content

[KT-76629] FIR: Fix wrong implicit visibility on Sealed classes. #5462

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ItsEmpa
Copy link

@ItsEmpa ItsEmpa commented Jun 7, 2025

@ItsEmpa ItsEmpa requested a review from a team as a code owner June 7, 2025 14:54
@ItsEmpa ItsEmpa requested a review from bnorm June 7, 2025 14:54
@ItsEmpa
Copy link
Author

ItsEmpa commented Jun 7, 2025

Hello, I would like to also add tests for these changes, but I'm not sure how to implement them. Is there any documentation on how the tests should get implemented? And if so, where? Thanks.

@ItsEmpa ItsEmpa changed the title FIR: Fix wrong implicit visibility on Sealed classes. [KT-76629] FIR: Fix wrong implicit visibility on Sealed classes. Jun 7, 2025
Copy link
Member

@bnorm bnorm left a comment

Choose a reason for hiding this comment

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

First off, thanks for your contribution!

Hello, I would like to also add tests for these changes, but I'm not sure how to implement them. Is there any documentation on how the tests should get implemented? And if so, where? Thanks.

Yes, we'll definitely need a test to validate desired behavior. I'm not able to find any complete documentation for tests, but here is a basic rundown:

Compiler tests are all contained here: https://github.com/JetBrains/kotlin/tree/master/compiler/testData.
You may find the other sealed class diagnostic tests a helpful reference as well as this README.
Also, you'll need to enable the WITH_EXTRA_CHECKERS directive for this test, since this is an IDE inspection.

In general, each .kt file is a test case that we run in various modes. So you'll need to create at least one new test file and add some sample code you want compiled which validates the fix. You can use the compiler devkit plugin to easily generate and run the test using the different runners: https://plugins.jetbrains.com/plugin/27550-kotlincompilerdevkit

And finally, we like to break up fixes like this which do not contain a test into two commits. The first commit adds just the test case so we can see what the state of the test data looks like before the fix. Then the second commit introduces the fix and updates the test data to match. This allows us to recreate the incorrect behavior of the compiler and validate the change correctly fixes the issue.

Let me know if you have any followup questions!

@ItsEmpa ItsEmpa force-pushed the fix/sealed-classes-visibility-modifier branch from 827f646 to 88e1adf Compare June 10, 2025 08:42
@ItsEmpa
Copy link
Author

ItsEmpa commented Jun 10, 2025

Thanks for the rundown, it helped a lot!

Compiler tests are all contained here: master/compiler/testData.

I think the correct place for these tests in particular was in master/compiler/fir/analysis-tests/testData, so i added them there instead.

I saw that some tests also had a second file, instead of being .kt it being .fir.txt. I wasn't sure on how to create one/what they are used for, so I didn't include one in my changes. Let me know if that's something that I should add as well.

And as you said, i first made a commit that adds a test that passes with the previous incorrect behaviour, and another commit that fixes that behaviour and modifies the test to match.

Let me know if there is something else i should change!

@ItsEmpa ItsEmpa requested a review from bnorm June 10, 2025 08:54
@bnorm bnorm self-assigned this Jun 30, 2025
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