File tree Expand file tree Collapse file tree 6 files changed +18
-19
lines changed Expand file tree Collapse file tree 6 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -3697,21 +3697,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
3697
3697
3698
3698
}
3699
3699
3700
- /** Type of a Quotes provided by a splice within a quote that took this context.
3701
- * It is only required if working with the reflection API.
3702
- *
3703
- * Usually it is infered by the quotes an splices typing. But sometimes it is necessary
3704
- * to explicitly state that a context is nested as in the following example:
3705
- *
3706
- * ```scala
3707
- * def run(using Quotes)(tree: qctx.reflect.Tree): Unit =
3708
- * def nested()(using qctx.Nested): Expr[Int] = '{ ${ makeExpr(tree) } + 1 }
3709
- * '{ ${ nested() } + 2 }
3710
- * def makeExpr(using Quotes)(tree: qctx.reflect.Tree): Expr[Int] = ???
3711
- * ```
3712
- */
3713
- type Nested = Quotes {
3714
- val reflect : self.reflect.type
3715
- }
3700
+ /** Type of a `Quotes` provided by a splice within a quote that took this context. */
3701
+ type Nested = Quotes
3716
3702
3717
3703
}
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ object Test
3
+ def run (using Quotes )(tree : qctx.reflect.Tree ): Unit =
4
+ ' { $ { makeExpr(tree) } + 1 } // error
5
+ def makeExpr (using Quotes )(tree : qctx.reflect.Tree ): Expr [Int ] = ???
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ object Test
3
+ def run (using q : Quotes )(tree : q.reflect.Tree ): Unit =
4
+ def nested ()(using q.Nested ): Expr [Int ] =
5
+ ' { $ { makeExpr(tree) } + 1 } // error
6
+ ' { $ { nested() } + 2 }
7
+
8
+ def makeExpr (using q : Quotes )(tree : q.reflect.Tree ): Expr [Int ] = ???
Original file line number Diff line number Diff line change 1
1
import scala .quoted ._
2
2
object Test
3
3
def run (using Quotes )(tree : quotes.reflect.Tree ): Unit =
4
+ def makeExpr (tree : quotes.reflect.Tree ): Expr [Int ] = ???
4
5
' { $ { makeExpr(tree) } + 1 }
5
- def makeExpr (using Quotes )(tree : quotes.reflect.Tree ): Expr [Int ] = ???
Original file line number Diff line number Diff line change 1
1
import scala .quoted ._
2
2
object Test
3
3
def run (using q : Quotes )(tree : q.reflect.Tree ): Unit =
4
+ def makeExpr (tree : q.reflect.Tree ): Expr [Int ] = ???
4
5
def nested ()(using q.Nested ): Expr [Int ] =
5
6
' { $ { makeExpr(tree) } + 1 }
6
7
' { $ { nested() } + 2 }
7
8
8
- def makeExpr (using q : Quotes )(tree : q.reflect.Tree ): Expr [Int ] = ???
Original file line number Diff line number Diff line change 1
1
stage1 code: ((q1: scala.quoted.Quotes) ?=> {
2
2
val x1: scala.Int = 2
3
- scala.quoted.runtime.Expr.quote[scala.Int](1.+(scala.quoted.runtime.Expr.nestedSplice[scala.Int](q1)(((evidence$5: q1.Nested ) ?=> scala.quoted.Expr.apply[scala.Int](x1)(scala.quoted.Liftable.IntLiftable[scala.Int])(evidence$5))))).apply(using q1)
3
+ scala.quoted.runtime.Expr.quote[scala.Int](1.+(scala.quoted.runtime.Expr.nestedSplice[scala.Int](q1)(((evidence$5: scala.quoted.Quotes ) ?=> scala.quoted.Expr.apply[scala.Int](x1)(scala.quoted.Liftable.IntLiftable[scala.Int])(evidence$5))))).apply(using q1)
4
4
})
5
5
3
You can’t perform that action at this time.
0 commit comments