Support valueOf of singleton tuples #17883
Swoorup
started this conversation in
Feature Requests
Replies: 0 comments 2 replies
-
For now, you can make a similar abstraction using final class ReflectType[T](val asValue: T) extends AnyVal {
type Refl = T
def refl: Refl = asValue
}
def reflectType[T](using refl: ReflectType[T]): refl.Refl = refl.refl
// forces bounds to be fixed in pattern match
final abstract class TypeBox[T]()
transparent inline given genReflectType[T]: ReflectType[T] = inline compiletime.erasedValue[TypeBox[T]] match {
case _: TypeBox[t *: ts] => ReflectType(compiletime.constValueTuple[t *: ts])
case _: TypeBox[EmptyTuple] => ReflectType(EmptyTuple)
case _: TypeBox[T] => ReflectType(valueOf[T])
}
val one: 1 = reflectType[1]
val many: (1,"msg",true) = reflectType[(1,"msg",true)] |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently this gives:
As @Odomontois pointed out in gitter something like this could support tuple singletons:
Beta Was this translation helpful? Give feedback.
All reactions