Skip to content

Commit 14c3718

Browse files
committed
Use Expr and Type to unpickle in CompilerInterface
1 parent 7cd3070 commit 14c3718

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,11 +2617,13 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
26172617

26182618
end reflect
26192619

2620-
def unpickleTerm(pickledQuote: PickledQuote): reflect.Term =
2621-
PickledQuotes.unpickleTerm(pickledQuote)(using reflect.rootContext)
2620+
def unpickleExpr(pickledQuote: PickledQuote): scala.quoted.Expr[Any] =
2621+
val tree = PickledQuotes.unpickleTerm(pickledQuote)(using reflect.rootContext)
2622+
new scala.internal.quoted.Expr(tree, hash)
26222623

2623-
def unpickleTypeTree(pickledQuote: PickledQuote): reflect.TypeTree =
2624-
PickledQuotes.unpickleTypeTree(pickledQuote)(using reflect.rootContext)
2624+
def unpickleType(pickledQuote: PickledQuote): scala.quoted.Type[?] =
2625+
val tree = PickledQuotes.unpickleTypeTree(pickledQuote)(using reflect.rootContext)
2626+
new scala.internal.quoted.Type(tree, hash)
26252627

26262628
def termMatch(scrutinee: reflect.Term, pattern: reflect.Term): Option[Tuple] =
26272629
treeMatch(scrutinee, pattern)

library/src/scala/internal/quoted/CompilerInterface.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ trait CompilerInterface { self: scala.quoted.QuoteContext =>
1212
/** Unpickle `repr` which represents a pickled `Expr` tree,
1313
* replacing splice nodes with `holes`
1414
*/
15-
def unpickleTerm(pickledQuote: PickledQuote): Term
15+
def unpickleExpr(pickledQuote: PickledQuote): scala.quoted.Expr[Any]
1616

1717
/** Unpickle `repr` which represents a pickled `Type` tree,
1818
* replacing splice nodes with `holes`
1919
*/
20-
def unpickleTypeTree(pickledQuote: PickledQuote): TypeTree
20+
def unpickleType(pickledQuote: PickledQuote): scala.quoted.Type[?]
2121

2222
/** Pattern matches the scrutinee against the pattern and returns a tuple
2323
* with the matched holes if successful.

library/src/scala/internal/quoted/PickledQuote.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ object PickledQuote:
1818

1919
def unpickleExpr[T](pickledQuote: PickledQuote): QuoteContext ?=> Expr[T] =
2020
val qctx = CompilerInterface.quoteContextWithCompilerInterface(summon[QuoteContext])
21-
val tree = qctx.unpickleTerm(pickledQuote)
22-
new scala.internal.quoted.Expr(tree, qctx.hashCode).asInstanceOf[Expr[T]]
21+
qctx.unpickleExpr(pickledQuote).asInstanceOf[Expr[T]]
2322

2423
def unpickleType[T](pickledQuote: PickledQuote): QuoteContext ?=> Type[T] =
2524
val qctx = CompilerInterface.quoteContextWithCompilerInterface(summon[QuoteContext])
26-
val tree = qctx.unpickleTypeTree(pickledQuote)
27-
new scala.internal.quoted.Type(tree, qctx.hashCode).asInstanceOf[Type[T]]
25+
qctx.unpickleType(pickledQuote).asInstanceOf[Type[T]]
2826

2927
/** Create an instance of PickledExpr from encoded tasty and sequence of labmdas to fill holes
3028
*

0 commit comments

Comments
 (0)