Skip to content

Commit 2bd3b6f

Browse files
committed
Simplify RawQuoted instantiations
1 parent 2ff30d6 commit 2bd3b6f

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import config.Printers.pickling
2020
import typer.Checking
2121
import config.Config
2222
import dotty.tools.dotc.quoted.PickledQuotes
23-
import dotty.tools.dotc.interpreter.RawExpr
23+
import dotty.tools.dotc.interpreter.RawQuoted
2424
import scala.quoted.Expr
2525

2626
/** Unpickler for typed trees
@@ -1035,7 +1035,7 @@ class TreeUnpickler(reader: TastyReader,
10351035
val splice = splices(idx)
10361036
val expr =
10371037
if (args.isEmpty) splice.asInstanceOf[Expr[_]]
1038-
else splice.asInstanceOf[Seq[Any] => Expr[_]](args.map(arg => new RawExpr(arg)))
1038+
else splice.asInstanceOf[Seq[Any] => Expr[_]](args.map(RawQuoted.apply))
10391039
PickledQuotes.quotedToTree(expr)
10401040
case _ =>
10411041
readPathTerm()

compiler/src/dotty/tools/dotc/interpreter/Interpreter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class Interpreter(implicit ctx: Context) {
5454
try {
5555
tree match {
5656
case Apply(_, quote :: Nil) if tree.symbol eq defn.quoteMethod =>
57-
new RawExpr(quote)
57+
RawQuoted(quote)
5858
case TypeApply(_, quote :: Nil) if tree.symbol eq defn.typeQuoteMethod =>
59-
new RawType(quote)
59+
RawQuoted(quote)
6060

6161
case Literal(Constant(c)) =>
6262
c.asInstanceOf[AnyRef]

compiler/src/dotty/tools/dotc/interpreter/RawExpr.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

compiler/src/dotty/tools/dotc/interpreter/RawQuoted.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ trait RawQuoted extends quoted.Quoted {
1010
def tree: tpd.Tree
1111
override def toString: String = s"${this.getClass.getName}(${tree.toString})"
1212
}
13+
14+
object RawQuoted {
15+
16+
def apply(tree: tpd.Tree): RawQuoted =
17+
if (tree.isTerm) new RawExpr(tree)
18+
else new RawType(tree)
19+
20+
private final class RawExpr(val tree: tpd.Tree) extends quoted.Expr[Any] with RawQuoted
21+
private final class RawType(val tree: tpd.Tree) extends quoted.Type[Any] with RawQuoted
22+
}

compiler/src/dotty/tools/dotc/interpreter/RawType.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)