-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add method to get an array of types a module is directly included in #8133
Add method to get an array of types a module is directly included in #8133
Conversation
Awesome. this will be quite useful if merged. I cant think of anything off the top of my head that also includes modules. |
idea: you could make a macro that generates a bunch of arbitrary modules to test |
Any use case for this? |
Mainly as a compliment to Ref https://forum.crystal-lang.org/t/type-all-includers/254 EDIT: I suppose |
How well does this work with querying generic modules? I'd like this method in but @asterite should sign off on this being complete, |
@RX14 Seems to work fine. module Bar(T)
end
module Foo
include Bar(String)
end
module Baz
include Bar(Bool)
end
{{Bar.all_includers.map &.name.stringify}} # => ["Foo", "Baz"] |
I think the main issue is what happens if a module is included by a generic type. It's probably the same issue we have with |
module Bar(T)
end
class Test(T)
include Bar(T)
end
{{Bar.all_includers.map &.name.stringify}} # => ["Test(T)"] Is what seems to happen. Same thing as |
I think this is acceptable behavior. |
Anything left to do here? |
Bump, this should be good to review. |
Rename to all_includers
Co-Authored-By: Sijawusz Pur Rahnama <sija@sija.pl>
854e92d
to
c03d27a
Compare
Also FWIW, #8483 will allow you to skip the generic type vars of the module (for both this and |
I want ary or brian to sign off on this. |
After working with this locally a bit I'm starting to think I should rename it to I'll push that tonight. |
Since this only includes types the module is directly included in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already dancing, so let's keep doing it
Questions:
How do I test this?Are there any other types that can include a module i should try?Any other ideas for a better name?I also noticed that types with generics include the generic type vars in their name. I would have thought
Gen(T)
would have just beenGen
...not sure if this is intended or not.EDIT: I added it to
macros.cr
, will include that in feedback fixes.