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

Add support for type aliases #16

Merged
merged 2 commits into from
Sep 7, 2020
Merged

Add support for type aliases #16

merged 2 commits into from
Sep 7, 2020

Conversation

EMH333
Copy link
Contributor

@EMH333 EMH333 commented Aug 14, 2020

As the title says, adds support for type aliases.

This should help resolve issue #9 because it becomes possible to do

typealias StringMap = Map<String, String>

and have a converter to convert from say StringMap to String which krush seems to find acceptable. Then just replace any instances of Map<String, String> with StringMap and it's off to the races.

This request was written out of a need to resolve issue #9 for a personal project, so it was either this or implement type properties correctly. Please let me know if I am missing any conventions! I didn't write any examples but could probably get some going in short order. Thanks!

@pjagielski
Copy link
Collaborator

Thanks, the code looks really well!
One thing I'm missing is having this TypeAliasEntity in example module with simple test case showing how to use type aliases - it is possible for you to add it?

@EMH333
Copy link
Contributor Author

EMH333 commented Aug 14, 2020

Sure, I'll add that this evening!

@EMH333
Copy link
Contributor Author

EMH333 commented Aug 15, 2020

I'm running into a few issues (I think with Exposed itself, it may not support typealias as well as I first thought) but I'll keep working on it and hopefully I can figure it out

This required slight modification to the code generation in order to properly
use the underlying type of an alias in certain locations and the name of
the typealias in others. Additionally, had to remove support for unwrapping
iterables from the string wrapper class but there aren't many
use cases for that feature that I can think of.
@EMH333
Copy link
Contributor Author

EMH333 commented Aug 27, 2020

@pjagielski Finally got it figured out. Just had to override a default implementation that was auto unrolling Iterable objects. As you may have predicted, adding an example helped find a few bugs in the overall process but now everything seems to be working as expected!

@EMH333
Copy link
Contributor Author

EMH333 commented Sep 4, 2020

@pjagielski ping :)

@pjagielski
Copy link
Collaborator

Looks good!

@pjagielski pjagielski merged commit e92f196 into TouK:master Sep 7, 2020
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