File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ import scala .tasty ._
3
+
4
+ inline def diveInto [T ]: String = $ { diveIntoImpl[T ]() }
5
+
6
+ def diveIntoImpl [T ]()(implicit qctx : QuoteContext , ttype : scala.quoted.Type [T ]): Expr [String ] =
7
+ import qctx .tasty ._
8
+ Expr ( unwindType(qctx.tasty)(typeOf[T ]) )
9
+
10
+ def unwindType (reflect : Reflection )(aType : reflect.Type ): String =
11
+ import reflect ._
12
+
13
+ aType match {
14
+ case AppliedType (t,tob) =>
15
+ val cs = t.classSymbol.get.primaryConstructor // this is shared
16
+ val a = cs.paramSymss // this call succeeds
17
+ // println("a: "+a)
18
+ val b = cs.paramSymss // this call explodes
19
+ // println("b: "+b)
20
+
21
+ case _ =>
22
+ }
23
+ " OK!"
24
+
Original file line number Diff line number Diff line change
1
+ def test =
2
+ diveInto[String ]
3
+ diveInto[List [Int ]]
4
+ diveInto[scala.collection.immutable.HashSet [String ]]
You can’t perform that action at this time.
0 commit comments