Skip to content

Commit cc5057c

Browse files
Merge pull request #4818 from dotty-staging/clean-quote-tests
Clean quote implementation
2 parents 0672b6d + 1432184 commit cc5057c

File tree

15 files changed

+10
-24
lines changed

15 files changed

+10
-24
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class Definitions {
683683
def Unpickler_unpickleType = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType")
684684

685685
lazy val TastyTopLevelSpliceModule = ctx.requiredModule("scala.tasty.TopLevelSplice")
686-
lazy val TastyTopLevelSplice_compilationTopLevelSplice = TastyTopLevelSpliceModule.requiredMethod("tastyContext")
686+
lazy val TastyTopLevelSplice_tastyContext = TastyTopLevelSpliceModule.requiredMethod("tastyContext")
687687

688688
lazy val EqType = ctx.requiredClassRef("scala.Eq")
689689
def EqClass(implicit ctx: Context) = EqType.symbol.asClass

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
146146
}
147147

148148
/** We are in a `~(...)` context that is not shadowed by a nested `'(...)` */
149-
def inSplice = outer != null && !inQuote
149+
def inSplice: Boolean = outer != null && !inQuote
150150

151151
/** We are not in a `~(...)` or a `'(...)` */
152-
def isRoot = outer == null
152+
def isRoot: Boolean = outer == null
153153

154154
/** A map from type ref T to expressions of type `quoted.Type[T]`".
155155
* These will be turned into splices using `addTags` and represent type variables
@@ -516,9 +516,9 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
516516
outer.enteredSyms.foreach(registerCapturer)
517517

518518
if (ctx.owner.owner.is(Macro)) {
519-
registerCapturer(defn.TastyTopLevelSplice_compilationTopLevelSplice)
519+
registerCapturer(defn.TastyTopLevelSplice_tastyContext)
520520
// Force a macro to have the context in first position
521-
forceCapture(defn.TastyTopLevelSplice_compilationTopLevelSplice)
521+
forceCapture(defn.TastyTopLevelSplice_tastyContext)
522522
// Force all parameters of the macro to be created in the definition order
523523
outer.enteredSyms.reverse.foreach(forceCapture)
524524
}
@@ -652,7 +652,7 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
652652

653653
private def isStage0Value(sym: Symbol)(implicit ctx: Context): Boolean =
654654
(sym.is(Inline) && sym.owner.is(Macro) && !defn.isFunctionType(sym.info)) ||
655-
sym == defn.TastyTopLevelSplice_compilationTopLevelSplice // intrinsic value at stage 0
655+
sym == defn.TastyTopLevelSplice_tastyContext // intrinsic value at stage 0
656656

657657
private def liftList(list: List[Tree], tpe: Type)(implicit ctx: Context): Tree = {
658658
list.foldRight[Tree](ref(defn.NilModule)) { (x, acc) =>

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ object Splicer {
9292
s"""Failed to evaluate inlined quote.
9393
| Caused by ${ex.getClass}: ${if (ex.getMessage == null) "" else ex.getMessage}
9494
| ${ex.getStackTrace.takeWhile(_.getClassName != "dotty.tools.dotc.transform.Splicer$").init.mkString("\n ")}
95-
""".stripMargin
95+
""".stripMargin
9696
ctx.error(msg, pos)
9797
EmptyTree
9898
}

library/src/scala/quoted/Type.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Type {
3131
object Types {
3232
/** A Type backed by a pickled TASTY tree */
3333
final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] {
34-
override def toString(): String = s"Type(<pickled>)"
34+
override def toString(): String = s"Type(<pickled tasty>)"
3535
}
3636

3737
/** An Type backed by a value */
@@ -41,6 +41,6 @@ object Types {
4141

4242
/** An Type backed by a tree */
4343
final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] {
44-
override def toString: String = s"Type(<raw>)"
44+
override def toString: String = s"Type(<tasty tree>)"
4545
}
4646
}

tests/pos/quote-0.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import scala.quoted._
22

33
import dotty.tools.dotc.quoted.Toolbox._
44

5-
65
object Macros {
76

87
inline def assert(expr: => Boolean): Unit =
9-
~ assertImpl('(expr))
8+
~assertImpl('(expr))
109

1110
def assertImpl(expr: Expr[Boolean]) =
1211
'{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~showExpr(expr)}") }

tests/run/tasty-custom-show/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty.TopLevelSplice
54
import scala.tasty.Tasty

tests/run/tasty-extractors-1/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty._
54

tests/run/tasty-extractors-2/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty._
54

tests/run/tasty-extractors-3/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty.TopLevelSplice
54
import scala.tasty.Tasty

tests/run/tasty-extractors-constants-1/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty._
54
import scala.tasty.util._

tests/run/tasty-extractors-owners/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty._
54
import scala.tasty.util.TreeTraverser

tests/run/tasty-extractors-types/quoted_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scala.quoted._
2-
import dotty.tools.dotc.quoted.Toolbox._
32

43
import scala.tasty._
54
import scala.tasty.util.TreeTraverser

tests/run/tasty-linenumber/quoted_1.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import scala.quoted._
22

3-
import dotty.tools.dotc.quoted.Toolbox._
4-
53
import scala.tasty._
64

75
class LineNumber(val value: Int) {

tests/run/tasty-location/quoted_1.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import scala.quoted._
22

3-
import dotty.tools.dotc.quoted.Toolbox._
4-
53
import scala.tasty._
64

75
case class Location(owners: List[String])

tests/run/tasty-positioned/quoted_1.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import scala.quoted._
22

3-
import dotty.tools.dotc.quoted.Toolbox._
4-
53
import scala.tasty._
64

75
case class Position(path: String, start: Int, end: Int,

0 commit comments

Comments
 (0)