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

[kotlin] J2K: Add JKTree processing step to remove redundant type projections #2741

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

Conversation

ermattt
Copy link

@ermattt ermattt commented Apr 22, 2024

In the spreadsheet, this one is listed as "REDUNDANT_PROJECTION."

Unfortunately this JKTree processing step isn't sufficient to remove the corresponding diagnostic-based postprocessing step: we need mutability analysis to run before we can remove redundant type projections from collections' type parameters (e.g. we can't remove the out from MutableList<out Foo>, but we can from List<out Foo>). If I omit the postprocessing step, there are 8 failing K1 tests (see attached screenshot).

I also tried implementing these changes by modifying JavaToJKTreeBuilder, but that had a bunch of unpleasant side effects, and didn't seem like a natural place to stick this logic.

NB: The test cases added here are largely based on my imagination, and might be overkill.

@abelkov @darthorimar @jocelynluizzi13

Screenshot 2024-04-21 at 9 49 32 PM

@abelkov abelkov self-assigned this Apr 22, 2024
@abelkov abelkov added the kotlin Pull requests for Kotlin IntelliJ plugin label Apr 22, 2024
@@ -1,4 +1,4 @@
internal interface INode
internal interface Node
internal open class A
internal class CC<T, K> : A() where T : INode?, T : Comparable<T?>?, K : Node?, K : Collection<K?>?
Copy link
Author

Choose a reason for hiding this comment

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

IMO the nullability change on T is good--I think removing the out/in earlier allows some of the nullability postprocessing steps to function at their best, since it's still T? before any postprocessing steps run (see attached screenshot). That being said, maybe I'm missing some important cases where it should stay nullable?
Screenshot 2024-04-21 at 9 16 29 PM

@ermattt ermattt force-pushed the 03-29-add_more_test_cases_for_redundant_type_projection branch from e0cc347 to 2c7112a Compare May 1, 2024 16:57
@ermattt ermattt force-pushed the 03-29-add_more_test_cases_for_redundant_type_projection branch from 2c7112a to e97c90e Compare May 1, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kotlin Pull requests for Kotlin IntelliJ plugin
Projects
None yet
3 participants