Skip to content

Commit 85f93bf

Browse files
Merge pull request #7929 from dotty-staging/move-quoted-unpickler
Move quoted.Unpickler to correct package
2 parents 4e33e5a + 62e978b commit 85f93bf

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ class Definitions {
711711
@tu lazy val QuotedMatchingSymClass: ClassSymbol = ctx.requiredClass("scala.quoted.matching.Sym")
712712
@tu lazy val TastyReflectionClass: ClassSymbol = ctx.requiredClass("scala.tasty.Reflection")
713713

714-
@tu lazy val Unpickler_unpickleExpr: Symbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr")
715-
@tu lazy val Unpickler_unpickleType: Symbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType")
714+
@tu lazy val Unpickler_unpickleExpr: Symbol = ctx.requiredMethod("scala.internal.quoted.Unpickler.unpickleExpr")
715+
@tu lazy val Unpickler_unpickleType: Symbol = ctx.requiredMethod("scala.internal.quoted.Unpickler.unpickleType")
716716

717717
@tu lazy val EqlClass: ClassSymbol = ctx.requiredClass("scala.Eql")
718718
def Eql_eqlAny(implicit ctx: Context): TermSymbol = EqlClass.companionModule.requiredMethod(nme.eqlAny)

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import dotty.tools.tasty.TastyString
2222
import scala.internal.quoted._
2323
import scala.reflect.ClassTag
2424

25-
import scala.runtime.quoted.Unpickler._
25+
import scala.internal.quoted.Unpickler._
2626

2727
object PickledQuotes {
2828
import tpd._

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import java.io._
44
import java.util.Base64
55
import java.nio.charset.StandardCharsets.UTF_8
66

7-
import scala.runtime.quoted.Unpickler.PickledQuote
7+
import scala.internal.quoted.Unpickler.PickledQuote
88

99
/** Utils for String representation of TASTY */
1010
object TastyString {

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import dotty.tools.dotc.tastyreflect.FromSymbol.{definitionFromSym, packageDefFr
1515
import dotty.tools.dotc.typer.Implicits.{AmbiguousImplicits, DivergingImplicit, NoMatchingImplicits, SearchFailure, SearchFailureType}
1616
import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans}
1717

18-
import scala.runtime.quoted.Unpickler
18+
import scala.internal.quoted.Unpickler
1919
import scala.tasty.reflect.CompilerInterface
2020

2121
import scala.tasty.reflect.IsInstanceOf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package scala.internal.quoted
2+
3+
import scala.quoted.{Expr, QuoteContext, Type}
4+
5+
/** Provides methods to unpickle `Expr` and `Type` trees. */
6+
object Unpickler {
7+
8+
type PickledQuote = List[String]
9+
type PickledExprArgs = Seq[Seq[Any] => (((given QuoteContext) => Expr[Any]) | Type[_])]
10+
type PickledTypeArgs = Seq[Seq[Any] => Type[_]]
11+
12+
/** Unpickle `repr` which represents a pickled `Expr` tree,
13+
* replacing splice nodes with `args`
14+
*/
15+
def unpickleExpr[T](repr: PickledQuote, args: PickledExprArgs): (given QuoteContext) => Expr[T] =
16+
summon[QuoteContext].tasty.internal.unpickleExpr(repr, args).asInstanceOf[Expr[T]]
17+
18+
/** Unpickle `repr` which represents a pickled `Type` tree,
19+
* replacing splice nodes with `args`
20+
*/
21+
def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): (given QuoteContext) => Type[T] =
22+
summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]]
23+
24+
}

library/src/scala/runtime/quoted/Unpickler.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
package scala.runtime.quoted // TODO move to scala.internal.quoted
1+
// TODO remove when reference compiler is updated
2+
package scala.runtime.quoted
23

34
import scala.quoted.{Expr, QuoteContext, Type}
45

56
/** Provides methods to unpickle `Expr` and `Type` trees. */
7+
@deprecated("Use scala.internal.quoted.Unpickler", "0.22.0")
68
object Unpickler {
79

810
type PickledQuote = List[String]

library/src/scala/tasty/reflect/CompilerInterface.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package scala.tasty.reflect // TODO move to scala.internal.tasty.reflect
22

33
import scala.quoted.QuoteContext
44
import scala.tasty.Reflection
5-
import scala.runtime.quoted.Unpickler
5+
import scala.internal.quoted.Unpickler
66

77
/** Tasty reflect abstract types
88
*

0 commit comments

Comments
 (0)