You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're trying to instantiate a NeoType from inside a macro, say from parsed input, it's very hard (at least I haven't found a way) to get type 'B', the wrapped type. It's not lying about someplace easy to get to accessible to Quotes. (You need the wrapped type to know how to parse/marshal raw input content into a typed thing.)
I figured that if I can navigate my way to validate() the input param to validate is the unwrapped type, so...
val_module=Symbol.requiredModule(typedName.toString) // the NeoTypeval_validate= _module.methodMember("validate").head // validate method
println("NeoTypeRef: "+ _module +"\n")
println("Validate Unhelpful: "+ _validate.paramSymss +"\n") // Should be what I need here... but sadly, no...
println("Validate Helpful: "+ _validate.info +"\n")
_validate.info matchcaseMethodType(_, paramss, _) =>// paramss.head is exactly what I want: the TypeRepr of the wrapped type
println(paramss.head)
This produces:
NeoTypeRef: object NonEmptyList
Validate Unhelpful: List(List(val input))
Validate Helpful: MethodType(List(input), List(AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class immutable)),class List),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)))), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Boolean))
AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class immutable)),class List),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)))
You can see the "normal" validate paramSymss is completely unhelpful--not sure why. The second info--the one with with the good stuff in it--required the -experimental flag to be set. All well and good, but who knows how stable that behavior will be in the future.
Is there away to more explicitly expose the wrapped type within a macro? Or is it already there and I haven't found the recipe to get to it yet?
The text was updated successfully, but these errors were encountered:
If you're trying to instantiate a NeoType from inside a macro, say from parsed input, it's very hard (at least I haven't found a way) to get type 'B', the wrapped type. It's not lying about someplace easy to get to accessible to Quotes. (You need the wrapped type to know how to parse/marshal raw input content into a typed thing.)
I figured that if I can navigate my way to validate() the input param to validate is the unwrapped type, so...
This produces:
You can see the "normal" validate paramSymss is completely unhelpful--not sure why. The second info--the one with with the good stuff in it--required the -experimental flag to be set. All well and good, but who knows how stable that behavior will be in the future.
Is there away to more explicitly expose the wrapped type within a macro? Or is it already there and I haven't found the recipe to get to it yet?
The text was updated successfully, but these errors were encountered: