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

Type node#name without generic args #8458

Conversation

Blacksmoke16
Copy link
Member

@Blacksmoke16 Blacksmoke16 commented Nov 9, 2019

Requires #8429. Will make this a draft until thats merged, then can rebase.

This PR allows getting the name of a TypeNode without the type's type vars. The main use case for this is when iterating over the subclasses of a parent type, where the children have type vars, and you're wanting to include data from a macro or annotation as generic type arguments. Currently since the type vars were always included you couldn't just do like {{"#{type.name}(#{ann[:theType]})".id}} since that would expand to say SomeType(T)(Foo). This allows skipping the (T) to make supplying the generic types easier.

See https://github.com/Blacksmoke16/assert/blob/master/src/assert.cr#L152 where I have to gsub the type arguments away before adding my own.

@straight-shoota
Copy link
Member

Maybe a a spec example that ensures the default behaviour with a generic type when ,generic_args is not set?

@Blacksmoke16 Blacksmoke16 deleted the TypeNode#name-without-generic-args branch November 17, 2019 19:36
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.

2 participants