Stop not generating private constant definitions #304
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.