Skip to content

Add scala.quoted.qctx #8939

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 1 commit into from
May 11, 2020
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
4 changes: 4 additions & 0 deletions library/src-bootstrapped/scala/quoted/qctx.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package scala.quoted

/** Current QuoteContext in scope */
def qctx(using qctx: QuoteContext): qctx.type = qctx
2 changes: 1 addition & 1 deletion tests/run-macros/reflect-select-value-class/assert_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object scalatest {

inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) }

def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using QuoteContext) : Expr[Unit] = {
import qctx.tasty._
import util._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/tasty-linenumber-2/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object LineNumber {

implicit inline def line: LineNumber = ${lineImpl}

def lineImpl(using qctx: QuoteContext) : Expr[LineNumber] = {
def lineImpl(using QuoteContext) : Expr[LineNumber] = {
import qctx.tasty._
'{new LineNumber(${rootPosition.startLine})}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/tasty-linenumber/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object LineNumber {
implicit inline def line[T >: Unit <: Unit]: LineNumber =
${lineImpl('[T])}

def lineImpl(x: Type[Unit])(using qctx: QuoteContext) : Expr[LineNumber] = {
def lineImpl(x: Type[Unit])(using QuoteContext) : Expr[LineNumber] = {
import qctx.tasty._
'{new LineNumber(${rootPosition.startLine})}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/run-macros/tasty-subtyping/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ object Macros {
inline def isSubTypeOf[T, U]: Boolean =
${isSubTypeOfImpl('[T], '[U])}

def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(using qctx: QuoteContext) : Expr[Boolean] = {
def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(using QuoteContext) : Expr[Boolean] = {
import qctx.tasty._
val isTypeEqual = t.unseal.tpe =:= u.unseal.tpe
isTypeEqual
}

def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U])(using qctx: QuoteContext) : Expr[Boolean] = {
def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U])(using QuoteContext) : Expr[Boolean] = {
import qctx.tasty._
val isTypeEqual = t.unseal.tpe <:< u.unseal.tpe
isTypeEqual
Expand Down
1 change: 0 additions & 1 deletion tests/run-staging/staged-tuples/StagedTuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ object StagedTuple {
}

def applyStaged[Tup <: NonEmptyTuple : Type, N <: Int : Type](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int])(using qctx: QuoteContext): Expr[Elem[Tup, N]] = {
import reflect._

if (!specialize) '{dynamicApply($tup, $n)}
else {
Expand Down