I'm trying to understand singleton types in shapeless and faced misunderstanding about singleton types compile-time type. Here is an example:
val x: Witness.`120`.T = 120.narrow
It works fine, but this constructions looks very unusual. What is Witness.120
? In IDE it points to some macro function selectDynamic
:
def selectDynamic(tpeSelector: String): Any = macro SingletonTypeMacros.witnessTypeImpl
which has compile-time type Any
and judging by the construction Witness.120.T
a type
member T
. This looks like magic... Can anyone give some explanation on what actually is going on when one writes something like:
val x: Witness.`120`.T = //...