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
Monkey patching
Class
to adddescendants
causes a confusion with theClass#descendants
method that Active Support adds and the signature on this method leaks out into the Tapioca generated RBI which causes type-checking problems in Core.Monkey patching
String
to addunderscore
causes a confusion with theString#underscore
method that Active Support adds and causes problems like https://discourse.shopify.io/t/file-naming-inflection-issues-with-tapioca-dsl-verify-in-ci/19663 (since the method later on gets replaced by the AS version and starts using application inflectors, etc, which we don't want, we just want a simple deterministic CamelCase to under_score implementation)Implementation
descendants
is arguably a reflection method, so I moved it toTapioca::Reflection
module, which is already included in the Base DSL class and SymbolGenerator class, asdescendants_of(klass)
. The added benefit is that through type parameters, we get better typing on this method, thus we need less casts.I moved the
underscore
method onto theGenerator
class and also duplicated it into the DSL test base class.Tests
No added tests.