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
287287 def let (rhs : Term )(body : Ident => Term ): Term = {
288288 import scala .quoted .QuoteContext
289289 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+ }
299299 }
300300 expr.unseal
301301 }
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import scala.quoted._
22
33object Macros {
44
5- inline def let [T ](rhs : T )(body : => T => Unit ): Unit =
5+ inline def let [T ](rhs : => T )(body : => T => Unit ): Unit =
66 $ { impl(' rhs , ' body ) }
77
88 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