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

Stop not generating private constant definitions #304

Merged
merged 8 commits into from May 12, 2021

Conversation

paracycle
Copy link
Member

@paracycle paracycle commented May 8, 2021

Motivation

Tapioca had been explicitly ignoring private constants almost since inception, since, at the time we believed that private constants were just that private to the gem, and thus, should not be a part of the external API of the gem.

For that reason, we had to add a lot of code to make sure that we would skip private constants if they appeared in mixins or as superclass, etc etc.

However, not only was this a lot of code to maintain, but it also turned out to be the wrong thing to do. Even if a constant is marked as private, it could very well be a part of a gem's public interface is the gem, for example, accepts parameters or, more likely, returns value of that private constant type in one of its public methods. That method's signature would end up referring to the private constant, but Tapioca would not have generated any definitions for it.

Similarly, some private constants do end up being mixed-in to some public types by some gems. Thus, even if those private constants are not directly accessible by client code, they would still be modifying some public interface.

This PR removes all the code that we had to remove private constants from the output.

Implementation

Most of the implementation is removing the code that was suppressing private constants from being output in RBI files.

However, it turns out that private constants are not always discovered by waking the constant hierarchy. Sometimes, they end up being discovered from a mixin, a superclass or a signature type. Thus, we add all such discovered types to the list of symbols to be processed, if they were not in our initial list. This allows us to generate RBI files that are more complete.

Tests

No new tests are added, existing tests are updated.

@paracycle paracycle force-pushed the uk-generate-private-constants branch from ba3dbbc to 9b66c3c Compare May 8, 2021 14:42
@paracycle paracycle force-pushed the uk-generate-private-constants branch from 9b66c3c to 6b9c67d Compare May 8, 2021 14:57
@paracycle paracycle force-pushed the uk-generate-private-constants branch from 75fbd12 to 8cf9e98 Compare May 8, 2021 20:28
@paracycle paracycle requested a review from a team May 8, 2021 20:28
@paracycle paracycle marked this pull request as ready for review May 8, 2021 20:28
@paracycle paracycle merged commit 31146de into master May 12, 2021
@paracycle paracycle deleted the uk-generate-private-constants branch May 12, 2021 13:30
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.

None yet

3 participants