Skip to content

Commit f24f10e

Browse files
giabaocheeseng
authored andcommitted
Fix a TODO in scalatestDotty's DiagramsMacro
1 parent 4b65d17 commit f24f10e

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

dotty/core/src/main/scala/org/scalatest/diagrams/DiagramsMacro.scala

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import org.scalatest.compatible.Assertion
2222

2323
object DiagramsMacro {
2424
// Transform the input expression by parsing out the anchor and generate expression that can support diagram rendering
25-
def parse(qctx: QuoteContext)(expr: qctx.tasty.Term): qctx.tasty.Term = {
26-
implicit val qctx2: qctx.type = qctx // TODO qctx should be given
25+
def parse(using qctx: QuoteContext)(expr: qctx.tasty.Term): qctx.tasty.Term = {
2726
import qctx.tasty._
2827
import util._
2928

@@ -67,7 +66,7 @@ object DiagramsMacro {
6766
(diagrams, others :+ arg)
6867
case (arg, tp) =>
6968
if (tp.widen.typeSymbol.show.startsWith("scala.Function")) (diagrams, others :+ arg)
70-
else (diagrams :+ parse(qctx)(arg), others)
69+
else (diagrams :+ parse(arg), others)
7170
}
7271
}
7372

@@ -87,7 +86,7 @@ object DiagramsMacro {
8786
case sel @ Select(qual, name) =>
8887
type T
8988
implicit val objTp: quoted.Type[T] = qual.tpe.seal.asInstanceOf[quoted.Type[T]]
90-
val obj = parse(qctx)(qual).seal.cast[DiagrammedExpr[T]]
89+
val obj = parse(qual).seal.cast[DiagrammedExpr[T]]
9190
val anchor = getAnchorForSelect(sel.asInstanceOf[Select])
9291

9392
'{
@@ -97,13 +96,13 @@ object DiagramsMacro {
9796

9897
case Block(stats, expr) =>
9998
// call parse recursively using the expr argument if it is a block
100-
Block(stats, parse(qctx)(expr))
99+
Block(stats, parse(expr))
101100
case Apply(sel @ Select(lhs, op), rhs :: Nil) =>
102101
val anchor = getAnchorForSelect(sel.asInstanceOf[Select])
103102
op match {
104103
case "||" | "|" =>
105-
val left = parse(qctx)(lhs).seal.cast[DiagrammedExpr[Boolean]]
106-
val right = parse(qctx)(rhs).seal.cast[DiagrammedExpr[Boolean]]
104+
val left = parse(lhs).seal.cast[DiagrammedExpr[Boolean]]
105+
val right = parse(rhs).seal.cast[DiagrammedExpr[Boolean]]
107106

108107
'{
109108
val l = $left
@@ -114,8 +113,8 @@ object DiagramsMacro {
114113
}
115114
}.unseal
116115
case "&&" | "&" =>
117-
val left = parse(qctx)(lhs).seal.cast[DiagrammedExpr[Boolean]]
118-
val right = parse(qctx)(rhs).seal.cast[DiagrammedExpr[Boolean]]
116+
val left = parse(lhs).seal.cast[DiagrammedExpr[Boolean]]
117+
val right = parse(rhs).seal.cast[DiagrammedExpr[Boolean]]
119118
'{
120119
val l = $left
121120
if (!l.value) l
@@ -127,7 +126,7 @@ object DiagramsMacro {
127126
case _ =>
128127
type T
129128
implicit val tpT: quoted.Type[T] = lhs.tpe.seal.asInstanceOf[quoted.Type[T]]
130-
val left = parse(qctx)(lhs)
129+
val left = parse(lhs)
131130

132131
val methTp = sel.tpe.widen.asInstanceOf[MethodType]
133132
val (diagrams, others) = handleArgs(methTp.paramTypes, rhs :: Nil)
@@ -146,7 +145,7 @@ object DiagramsMacro {
146145
type T
147146
implicit val tpT: quoted.Type[T] = lhs.tpe.seal.asInstanceOf[quoted.Type[T]]
148147

149-
val left = parse(qctx)(lhs)
148+
val left = parse(lhs)
150149
val anchor = getAnchorForSelect(sel.asInstanceOf[Select])
151150

152151
val methTp = sel.tpe.widen.asInstanceOf[MethodType]
@@ -165,8 +164,8 @@ object DiagramsMacro {
165164
if isImplicitMethodType(f.tpe) =>
166165
type T
167166
implicit val tpT: quoted.Type[T] = lhs.tpe.seal.asInstanceOf[quoted.Type[T]]
168-
val left = parse(qctx)(lhs)
169-
val right = parse(qctx)(rhs)
167+
val left = parse(lhs)
168+
val right = parse(rhs)
170169

171170
val anchor = getAnchorForSelect(sel.asInstanceOf[Select])
172171

@@ -187,7 +186,7 @@ object DiagramsMacro {
187186
type T
188187
implicit val tpT: quoted.Type[T] = lhs.tpe.seal.asInstanceOf[quoted.Type[T]]
189188

190-
val left = parse(qctx)(lhs)
189+
val left = parse(lhs)
191190
val anchor = getAnchorForSelect(sel.asInstanceOf[Select])
192191

193192
val methTp = fun.tpe.widen.asInstanceOf[MethodType]
@@ -207,7 +206,7 @@ object DiagramsMacro {
207206
type T
208207
implicit val tpT: quoted.Type[T] = lhs.tpe.seal.asInstanceOf[quoted.Type[T]]
209208

210-
val left = parse(qctx)(lhs)
209+
val left = parse(lhs)
211210
val anchor = getAnchorForSelect(sel.asInstanceOf[Select])
212211

213212
let(left) { l =>
@@ -224,9 +223,9 @@ object DiagramsMacro {
224223
def transform(
225224
helper: Expr[(DiagrammedExpr[Boolean], Any, String, source.Position) => Assertion],
226225
condition: Expr[Boolean], pos: Expr[source.Position], clue: Expr[Any], sourceText: String
227-
)(implicit qctx: QuoteContext): Expr[Assertion] = {
226+
)(using qctx: QuoteContext): Expr[Assertion] = {
228227
import qctx.tasty._
229-
val diagExpr = parse(qctx)(condition.unseal.underlyingArgument).seal.cast[DiagrammedExpr[Boolean]]
228+
val diagExpr = parse(condition.unseal.underlyingArgument).seal.cast[DiagrammedExpr[Boolean]]
230229
'{ $helper($diagExpr, $clue, ${Expr(sourceText)}, $pos) }
231230
}
232231
}

0 commit comments

Comments
 (0)