File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ public enum JavaEnum { ABC , DEF , GHI }
Original file line number Diff line number Diff line change
1
+ import scala .deriving .Mirror
2
+ import scala .compiletime .*
3
+ import scala .reflect .ClassTag
4
+ import scala .annotation .implicitNotFound
5
+
6
+
7
+ trait TSType [T ]
8
+ object TSType extends DefaultTSTypes with TSTypeMacros
9
+
10
+ trait TSNamedType [T ] extends TSType [T ]
11
+
12
+ trait DefaultTSTypes extends JavaTSTypes
13
+ trait JavaTSTypes {
14
+ given javaEnumTSType [E <: java.lang.Enum [E ]: ClassTag ]: TSType [E ] = ???
15
+ given javaEnumTSNamedType [E <: java.lang.Enum [E ]: ClassTag ]: TSNamedType [E ] = ???
16
+ }
17
+ object DefaultTSTypes extends DefaultTSTypes
18
+ trait TSTypeMacros {
19
+ inline given [T : Mirror .Of ]: TSType [T ] = derived[T ]
20
+ inline def derived [T ](using m : Mirror .Of [T ]): TSType [T ] = {
21
+ val elemInstances = summonAll[m.MirroredElemTypes ]
22
+ ???
23
+ }
24
+
25
+ private inline def summonAll [T <: Tuple ]: List [TSType [_]] = {
26
+ inline erasedValue[T ] match {
27
+ case _ : EmptyTuple => Nil
28
+ case _ : (t *: ts) => summonInline[TSType [t]] :: summonAll[ts]
29
+ }
30
+ }
31
+ }
32
+
33
+ @ main def Test =
34
+ summon[TSType [JavaEnum ]]
35
+ summon[TSNamedType [JavaEnum ]]
You can’t perform that action at this time.
0 commit comments