Skip to content

Commit 14c5d4d

Browse files
nicolasstuckicheeseng
authored andcommitted
Use scala.quoted.Expr.apply
1 parent 7610931 commit 14c5d4d

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

common-test.dotty/src/main/scala/org/scalatest/LineNumberHelper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ private[scalatest] trait LineNumberHelper {
1010
object LineNumberMacro {
1111
def thisLineNumberImpl(implicit qctx: QuoteContext): Expr[Int] = {
1212
import qctx.tasty._
13-
rootPosition.startLine.toExpr
13+
Expr(rootPosition.startLine)
1414
}
1515
}

scalactic.dotty/src/main/scala/org/scalactic/BooleanMacro.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object BooleanMacro {
4242
import util._
4343

4444
def exprStr: String = condition.show
45-
def defaultCase = '{ Bool.simpleMacroBool($condition, ${exprStr.toExpr}, $prettifier) }
45+
def defaultCase = '{ Bool.simpleMacroBool($condition, ${Expr(exprStr)}, $prettifier) }
4646
def isImplicitMethodType(tp: Type): Boolean =
4747
Type.IsMethodType.unapply(tp).flatMap(tp => if tp.isImplicit then Some(true) else None).nonEmpty
4848

@@ -87,7 +87,7 @@ object BooleanMacro {
8787
val l = left.seal
8888
val r = right.seal
8989
val b = result.seal.cast[Boolean]
90-
val code = '{ Bool.binaryMacroBool($l, ${ op.toExpr }, $r, $b, $prettifier) }
90+
val code = '{ Bool.binaryMacroBool($l, ${ Expr(op) }, $r, $b, $prettifier) }
9191
code.unseal
9292
}
9393
}
@@ -104,7 +104,7 @@ object BooleanMacro {
104104
val l = left.seal
105105
val r = right.seal
106106
val b = result.seal.cast[Boolean]
107-
val code = '{ Bool.binaryMacroBool($l, ${op.toExpr}, $r, $b, $prettifier) }
107+
val code = '{ Bool.binaryMacroBool($l, ${Expr(op)}, $r, $b, $prettifier) }
108108
code.unseal
109109
}
110110
}
@@ -138,7 +138,7 @@ object BooleanMacro {
138138
val l = left.seal
139139
val r = right.seal
140140
val res = result.seal
141-
val code = '{ Bool.lengthSizeMacroBool($l, ${op.toExpr}, $res, $r, $prettifier) }
141+
val code = '{ Bool.lengthSizeMacroBool($l, ${Expr(op)}, $res, $r, $prettifier) }
142142
code.unseal
143143
}
144144
}
@@ -152,7 +152,7 @@ object BooleanMacro {
152152
val l = left.seal
153153
val r = right.seal
154154
val res = result.seal
155-
val code = '{ Bool.lengthSizeMacroBool($l, ${op.toExpr}, $res, $r, $prettifier) }
155+
val code = '{ Bool.lengthSizeMacroBool($l, ${Expr(op)}, $res, $r, $prettifier) }
156156
code.unseal
157157
}
158158
}
@@ -189,7 +189,7 @@ object BooleanMacro {
189189
val l = left.seal
190190
val r = right.seal
191191
val b = result.seal.cast[Boolean]
192-
val code = '{ Bool.binaryMacroBool($l, ${ op.toExpr }, $r, $b, $prettifier) }
192+
val code = '{ Bool.binaryMacroBool($l, ${ Expr(op) }, $r, $b, $prettifier) }
193193
code.unseal
194194
}
195195
}
@@ -203,7 +203,7 @@ object BooleanMacro {
203203
val l = left.seal
204204
val r = right.seal
205205
val b = result.seal.cast[Boolean]
206-
val code = '{ Bool.binaryMacroBool($l, ${op.toExpr}, $r, $b, $prettifier) }
206+
val code = '{ Bool.binaryMacroBool($l, ${Expr(op)}, $r, $b, $prettifier) }
207207
code.unseal
208208
}
209209
}
@@ -212,7 +212,7 @@ object BooleanMacro {
212212
case Apply(sel @ Select(lhs, op @ ("isEmpty" | "nonEmpty")), Nil) =>
213213
let(lhs) { l =>
214214
val res = l.select(sel.symbol).appliedToArgs(Nil).seal.cast[Boolean]
215-
'{ Bool.unaryMacroBool(${l.seal}, ${ op.toExpr }, $res, $prettifier) }.unseal
215+
'{ Bool.unaryMacroBool(${l.seal}, ${ Expr(op) }, $res, $prettifier) }.unseal
216216
}.seal.cast[Bool]
217217

218218
case Select(left, "unary_!") =>
@@ -222,13 +222,13 @@ object BooleanMacro {
222222
case sel @ Select(left, op @ ("isEmpty" | "nonEmpty")) =>
223223
let(left) { l =>
224224
val res = l.select(sel.symbol).seal.cast[Boolean]
225-
'{ Bool.unaryMacroBool(${l.seal}, ${ op.toExpr }, $res, $prettifier) }.unseal
225+
'{ Bool.unaryMacroBool(${l.seal}, ${ Expr(op) }, $res, $prettifier) }.unseal
226226
}.seal.cast[Bool]
227227

228228
case TypeApply(sel @ Select(lhs, "isInstanceOf"), targs) =>
229229
let(lhs) { l =>
230230
val res = l.select(sel.symbol).appliedToTypeTrees(targs).seal.cast[Boolean]
231-
val name = targs.head.tpe.show.toExpr
231+
val name = Expr(targs.head.tpe.show)
232232
'{ Bool.isInstanceOfMacroBool(${l.seal}, "isInstanceOf", $name, $res, $prettifier) }.unseal
233233
}.seal.cast[Bool]
234234

scalactic.dotty/src/main/scala/org/scalactic/Requirements.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ object RequirementsMacro {
268268

269269
val argStr: List[Expr[String]] = arguments.unseal.underlyingArgument match {
270270
case Typed(Repeated(args, _), _) => // only sequence literal
271-
args.map(arg => arg.seal.cast[Any].show.toExpr)
271+
args.map(arg => Expr(arg.seal.cast[Any].show))
272272
case _ =>
273273
qctx.error("requireNonNull can only be used with sequence literal, not `seq : _*`")
274274
return '{}

scalactic.dotty/src/main/scala/org/scalactic/Snapshots.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ object SnapshotsMacro {
231231
val snapshots: List[Expr[Snapshot]] = expressions.unseal.underlyingArgument match {
232232
case Typed(Repeated(args, _), _) => // only sequence literal
233233
args.map { arg =>
234-
val str = arg.seal.cast[Any].show.toExpr
234+
val str = Expr(arg.seal.cast[Any].show)
235235
'{ Snapshot($str, ${ arg.seal.cast[Any] }) }
236236
}
237237
case arg =>

scalactic.dotty/src/main/scala/org/scalactic/source/Position.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object Position {
7373
val fileName: String = file.jpath.getFileName.toString
7474
val filePath: String = if (showScalacticFillFilePathnames) file.toString else Resources.pleaseDefineScalacticFillFilePathnameEnvVar
7575
val lineNo: Int = rootPosition.startLine
76-
'{ Position(${fileName.toExpr}, ${filePath.toExpr}, ${lineNo.toExpr}) }
76+
'{ Position(${Expr(fileName)}, ${Expr(filePath)}, ${Expr(lineNo)}) }
7777
}
7878

7979
}

scalactic.dotty/src/main/scala/org/scalactic/source/TypeInfoMacro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object TypeInfoMacro {
2828
def genTypeInfo[T](tp: Type[T])(implicit qctx: QuoteContext): Expr[TypeInfo[T]] = {
2929
import qctx.tasty._
3030

31-
val name = tp.show.toExpr
31+
val name = Expr(tp.show)
3232
'{ TypeInfo[$tp]($name) }
3333
}
3434
}

scalatest.dotty/src/main/scala/org/scalatest/Assertions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ object Assertions extends Assertions {
13431343
import scala.quoted._
13441344

13451345
def stripMarginImpl(x: String)(implicit qctx: QuoteContext): Expr[String] =
1346-
new scala.collection.immutable.StringOps(x).stripMargin.toExpr
1346+
Expr(new scala.collection.immutable.StringOps(x).stripMargin)
13471347

13481348
@deprecated("The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, so NormalResult will be removed in a future version of ScalaTest")
13491349
case class NormalResult(result: Any) extends Throwable {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ object DiagramsMacro {
4545

4646
def getAnchorForSelect(sel: Select): Expr[Int] = {
4747
if (sel.name == "unary_!")
48-
(sel.pos.startColumn - rootPosition.startColumn).toExpr
48+
Expr(sel.pos.startColumn - rootPosition.startColumn)
4949
else {
5050
val selOffset = sel.pos.endColumn - sel.qualifier.pos.endColumn - sel.name.length
51-
(sel.qualifier.pos.endColumn + selOffset - rootPosition.startColumn).toExpr
51+
Expr(sel.qualifier.pos.endColumn + selOffset - rootPosition.startColumn)
5252
}
5353
}
5454

5555
def getAnchor(expr: Term): Expr[Int] = {
5656
// -1 to match scala2 position
57-
// ((expr.unseal.pos.endColumn + expr.unseal.pos.startColumn - 1) / 2 - rootPosition.startColumn).toExpr
58-
(expr.pos.startColumn - rootPosition.startColumn).toExpr
57+
// Expr((expr.unseal.pos.endColumn + expr.unseal.pos.startColumn - 1) / 2 - rootPosition.startColumn)
58+
Expr(expr.pos.startColumn - rootPosition.startColumn)
5959
}
6060

6161
def handleArgs(argTps: List[Type], args: List[Term]): (List[Term], List[Term]) =
@@ -225,6 +225,6 @@ object DiagramsMacro {
225225
)(implicit qctx: QuoteContext): Expr[Assertion] = {
226226
import qctx.tasty._
227227
val diagExpr = parse(qctx)(condition.unseal.underlyingArgument).seal.cast[DiagrammedExpr[Boolean]]
228-
'{ $helper($diagExpr, $clue, ${sourceText.toExpr}, $pos) }
228+
'{ $helper($diagExpr, $clue, ${Expr(sourceText)}, $pos) }
229229
}
230230
}

0 commit comments

Comments
 (0)