Skip to content

Propagate the "real" type of an opaque type alias to the Reflection API #8163

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

Closed
gzoller opened this issue Jan 31, 2020 · 3 comments
Closed

Comments

@gzoller
Copy link
Contributor

gzoller commented Jan 31, 2020

minimized example

opaque type PhoneNumber = String
case class Person( phone: PhoneNumber )

For a serialization library I'm working on, I can reflect on Person and get information on its fields, i.e. phone. I can know that its type is PhoneNumber. I can't (today) learn that PhoneNumber's "real" type is String.

The serializer would need this to handle field phone as a String for serialization purposes.

Compilation output

Today the reflected TypeRef for field phone's type is something like this:

TypeRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class com)),module mypkg),Dog$package),PhoneNumber)

expectation

Somewhere in the TypeRef, add information about PhoneNumber's base type. Please (please) not just a label "String" or something flat like that. I need to be able to continue reflecting on the base type, especially if it isn't a primitive type! (A wrapped TypeRef?)

@gzoller
Copy link
Contributor Author

gzoller commented Jan 31, 2020

Working on a PR for this. I think I may have something working.

@gzoller
Copy link
Contributor Author

gzoller commented Feb 3, 2020

PR submitted: HERE

@nicolasstucki
Copy link
Contributor

Closed by #8176

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

No branches or pull requests

2 participants