Skip to content

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

@gzoller

Description

@gzoller

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?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions