@@ -16,7 +16,7 @@ class SLSelect[S]:
16
16
17
17
def fold [S ](s0: S )(step : (S ,SLSelect [S ])=> S ): S = {
18
18
???
19
- }
19
+ }
20
20
21
21
def fold_async [S ](s0: S )(step : (S ,SLSelect [S ])=> Future [S ]): Future [S ] = {
22
22
???
@@ -27,7 +27,7 @@ class SLSelect[S]:
27
27
await(s0.onRead(ch)(f).runAsync())
28
28
29
29
def runAsync (): Future [S ] = ???
30
-
30
+
31
31
32
32
33
33
object X :
@@ -36,30 +36,30 @@ object X:
36
36
processImpl[T ](' f )
37
37
}
38
38
39
- def processImpl [T : Type ](t: Expr [T ])(using Quotes ): Expr [Future [T ]] =
39
+ def processImpl [T : Type ](t: Expr [T ])(using Quotes ): Expr [Future [T ]] =
40
40
import quotes .reflect ._
41
41
val r = processTree[T ](t.asTerm)
42
42
r.asExprOf[Future [T ]]
43
43
44
-
45
- def processTree [T : Type ](using Quotes )(t : quotes.reflect.Term ): quotes.reflect.Term =
44
+
45
+ def processTree [T : Type ](using Quotes )(t : quotes.reflect.Term ): quotes.reflect.Term =
46
46
import quotes .reflect ._
47
47
val r : Term = t match
48
48
case Inlined (_,List (),body) => processTree(body)
49
- case Inlined (d,bindings,body) =>
49
+ case Inlined (d,bindings,body) =>
50
50
Inlined (d,bindings,processTree[T ](body))
51
51
case Block (stats,expr) => Block (stats,processTree(expr))
52
52
case Apply (Apply (TypeApply (Select (x," fold" ),targs),List (state)),List (fun)) =>
53
- val nFun = processLambda[T ](fun)
53
+ val nFun = processLambda[T ](fun)
54
54
Apply (Apply (TypeApply (Select .unique(x," fold_async" ),targs),List (state)),List (nFun))
55
55
case Apply (TypeApply (Ident (" await" ),targs),List (body)) => body
56
- case Typed (x,tp) => Typed (processTree(x), Inferred (TypeRepr .of[Future ].appliedTo(tp.tpe)) )
56
+ case Typed (x : Term ,tp) => Typed (processTree(x), Inferred (TypeRepr .of[Future ].appliedTo(tp.tpe)) )
57
57
case _ => throw new RuntimeException (s " tree not recoginized: $t" )
58
58
val checker = new TreeMap () {}
59
59
checker.transformTerm(r)(Symbol .spliceOwner)
60
60
r
61
-
62
- def processLambda [T : Type ](using Quotes )(fun : quotes.reflect.Term ): quotes.reflect.Term =
61
+
62
+ def processLambda [T : Type ](using Quotes )(fun : quotes.reflect.Term ): quotes.reflect.Term =
63
63
import quotes .reflect ._
64
64
65
65
def changeArgs (oldArgs: List [Tree ], newArgs: List [Tree ], body: Term , owner : Symbol ): Term =
0 commit comments