Is there anyway, in Scala, to get the Singleton type of something from the more general type?
问题 I have a situation where I'm trying to use implicit resolution on a singleton type. This works perfectly fine if I know that singleton type at compile time: object Main { type SS = String with Singleton trait Entry[S <: SS] { type out val value: out } implicit val e1 = new Entry["S"] { type out = Int val value = 3 } implicit val e2 = new Entry["T"] { type out = String val value = "ABC" } def resolve[X <: SS](s: X)(implicit x: Entry[X]): x.value.type = { x.value } def main(args: Array[String])