Skip to content

Move quoted.Unpickler to correct package #7929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ class Definitions {
@tu lazy val QuotedMatchingSymClass: ClassSymbol = ctx.requiredClass("scala.quoted.matching.Sym")
@tu lazy val TastyReflectionClass: ClassSymbol = ctx.requiredClass("scala.tasty.Reflection")

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

@tu lazy val EqlClass: ClassSymbol = ctx.requiredClass("scala.Eql")
def Eql_eqlAny(implicit ctx: Context): TermSymbol = EqlClass.companionModule.requiredMethod(nme.eqlAny)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import dotty.tools.tasty.TastyString
import scala.internal.quoted._
import scala.reflect.ClassTag

import scala.runtime.quoted.Unpickler._
import scala.internal.quoted.Unpickler._

object PickledQuotes {
import tpd._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TastyString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.io._
import java.util.Base64
import java.nio.charset.StandardCharsets.UTF_8

import scala.runtime.quoted.Unpickler.PickledQuote
import scala.internal.quoted.Unpickler.PickledQuote

/** Utils for String representation of TASTY */
object TastyString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import dotty.tools.dotc.tastyreflect.FromSymbol.{definitionFromSym, packageDefFr
import dotty.tools.dotc.typer.Implicits.{AmbiguousImplicits, DivergingImplicit, NoMatchingImplicits, SearchFailure, SearchFailureType}
import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans}

import scala.runtime.quoted.Unpickler
import scala.internal.quoted.Unpickler
import scala.tasty.reflect.CompilerInterface

import scala.tasty.reflect.IsInstanceOf
Expand Down
24 changes: 24 additions & 0 deletions library/src/scala/internal/quoted/Unpickler.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package scala.internal.quoted

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

/** Provides methods to unpickle `Expr` and `Type` trees. */
object Unpickler {

type PickledQuote = List[String]
type PickledExprArgs = Seq[Seq[Any] => (((given QuoteContext) => Expr[Any]) | Type[_])]
type PickledTypeArgs = Seq[Seq[Any] => Type[_]]

/** Unpickle `repr` which represents a pickled `Expr` tree,
* replacing splice nodes with `args`
*/
def unpickleExpr[T](repr: PickledQuote, args: PickledExprArgs): (given QuoteContext) => Expr[T] =
summon[QuoteContext].tasty.internal.unpickleExpr(repr, args).asInstanceOf[Expr[T]]

/** Unpickle `repr` which represents a pickled `Type` tree,
* replacing splice nodes with `args`
*/
def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): (given QuoteContext) => Type[T] =
summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]]

}
4 changes: 3 additions & 1 deletion library/src/scala/runtime/quoted/Unpickler.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package scala.runtime.quoted // TODO move to scala.internal.quoted
// TODO remove when reference compiler is updated
package scala.runtime.quoted

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

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

type PickledQuote = List[String]
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/tasty/reflect/CompilerInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scala.tasty.reflect // TODO move to scala.internal.tasty.reflect

import scala.quoted.QuoteContext
import scala.tasty.Reflection
import scala.runtime.quoted.Unpickler
import scala.internal.quoted.Unpickler

/** Tasty reflect abstract types
*
Expand Down