File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
library/src-bootstrapped/scala/tasty/reflect
tests/run-macros/tasty-unsafe-let Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -287,15 +287,15 @@ trait TreeUtils
287
287
def let (rhs : Term )(body : Ident => Term ): Term = {
288
288
import scala .quoted .QuoteContext
289
289
given as QuoteContext = new QuoteContext (this )
290
- type T // TODO probably it is better to use the Sealed contruct rather than let the user create their own existential type
291
- implicit val rhsTpe : quoted. Type [ T ] = rhs.tpe.seal. asInstanceOf [quoted. Type [ T ]]
292
- val rhsExpr = rhs.seal.cast[ T ]
293
- val expr = ' {
294
- val x = $rhsExpr
295
- $ {
296
- val id = ( ' x ).unseal. asInstanceOf [ Ident ]
297
- body(id).seal
298
- }
290
+ val expr = (rhs.seal : @ unchecked) match {
291
+ case ' { $rhsExpr : $t } =>
292
+ ' {
293
+ val x = $rhsExpr
294
+ $ {
295
+ val id = ( ' x ).unseal. asInstanceOf [ Ident ]
296
+ body(id).seal
297
+ }
298
+ }
299
299
}
300
300
expr.unseal
301
301
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import scala.quoted._
2
2
3
3
object Macros {
4
4
5
- inline def let [T ](rhs : T )(body : => T => Unit ): Unit =
5
+ inline def let [T ](rhs : => T )(body : => T => Unit ): Unit =
6
6
$ { impl(' rhs , ' body ) }
7
7
8
8
private def impl [T ](rhs : Expr [T ], body : Expr [T => Unit ]) given (qctx : QuoteContext ): Expr [Unit ] = {
You can’t perform that action at this time.
0 commit comments