Skip to content

Rename QuoteContext.NestedContext to QuoteContext.Nested #8938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/src/scala/internal/quoted/CompileTime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object CompileTime {
* `ctx` is the `QuoteContext` that the quote of this splice uses.
*/
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.exprNestedSplice`")
def exprNestedSplice[T](ctx: QuoteContext)(x: ctx.NestedContext ?=> Expr[T]): T = ???
def exprNestedSplice[T](ctx: QuoteContext)(x: ctx.Nested ?=> Expr[T]): T = ???

/** A type quote is desugared by the compiler into a call to this method */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.typeQuote`")
Expand Down
4 changes: 2 additions & 2 deletions library/src/scala/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class QuoteContext(val tasty: scala.tasty.Reflection) { self =>
*
* ```scala
* def run(using qctx: QuoteContext)(tree: qctx.tasty.Tree): Unit =
* def nested()(using qctx.NestedContext): Expr[Int] = '{ ${ makeExpr(tree) } + 1 }
* def nested()(using qctx.Nested): Expr[Int] = '{ ${ makeExpr(tree) } + 1 }
* '{ ${ nested() } + 2 }
* def makeExpr(using qctx: QuoteContext)(tree: qctx.tasty.Tree): Expr[Int] = ???
* ```
*/
type NestedContext = QuoteContext {
type Nested = QuoteContext {
val tasty: self.tasty.type
}

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i8045b.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import scala.quoted._
object Test
def run(using qctx: QuoteContext)(tree: qctx.tasty.Tree): Unit =
def nested()(using qctx.NestedContext): Expr[Int] =
def nested()(using qctx.Nested): Expr[Int] =
'{ ${ makeExpr(tree) } + 1 }
'{ ${ nested() } + 2 }

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/splice-with-explicit-context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ def f(a: Expr[Int])(using qctx: QuoteContext): Unit =

'{ val x: Int = ${ (using qctx2) => a } }

'{ val x: Int = ${ (using qctx2: qctx.NestedContext) => a } }
'{ val x: Int = ${ (using qctx2: qctx.Nested) => a } }
2 changes: 1 addition & 1 deletion tests/run-staging/quote-nested-2.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
((qctx: scala.quoted.QuoteContext) ?=> {
val a: scala.quoted.Expr[scala.Int] = scala.internal.quoted.CompileTime.exprQuote[scala.Int](4).apply(using qctx)
((evidence$2: qctx.NestedContext) ?=> a).asInstanceOf[scala.ContextFunction1[scala.quoted.QuoteContext, scala.quoted.Expr[scala.Int]]].apply(using qctx)
((evidence$2: qctx.Nested) ?=> a).asInstanceOf[scala.ContextFunction1[scala.quoted.QuoteContext, scala.quoted.Expr[scala.Int]]].apply(using qctx)
})
2 changes: 1 addition & 1 deletion tests/run-staging/quote-nested-5.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
((qctx: scala.quoted.QuoteContext) ?=> {
val a: scala.quoted.Expr[scala.Int] = scala.internal.quoted.CompileTime.exprQuote[scala.Int](4).apply(using qctx)
((qctx2: scala.quoted.QuoteContext) ?=> ((evidence$3: qctx2.NestedContext) ?=> a).asInstanceOf[scala.ContextFunction1[scala.quoted.QuoteContext, scala.quoted.Expr[scala.Int]]].apply(using qctx2)).apply(using qctx)
((qctx2: scala.quoted.QuoteContext) ?=> ((evidence$3: qctx2.Nested) ?=> a).asInstanceOf[scala.ContextFunction1[scala.quoted.QuoteContext, scala.quoted.Expr[scala.Int]]].apply(using qctx2)).apply(using qctx)
})