Skip to content

Commit ecfc0a2

Browse files
committed
Cleanup Unpickler.PickledArgs
1 parent 1b24694 commit ecfc0a2

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ object PickledQuotes {
6060
}.apply(tp)
6161

6262
/** Unpickle the tree contained in the TastyExpr */
63-
def unpickleExpr(tasty: PickledQuote, args: PickledExprArgs)(implicit ctx: Context): Tree = {
63+
def unpickleExpr(tasty: PickledQuote, args: PickledArgs)(implicit ctx: Context): Tree = {
6464
val tastyBytes = TastyString.unpickle(tasty)
6565
val unpickled = unpickle(tastyBytes, args, isType = false)(ctx.addMode(Mode.ReadPositions))
6666
/** Force unpickling of the tree, removes the spliced type `@quotedTypeTag type` definitions and dealiases references to `@quotedTypeTag type` */
@@ -76,7 +76,7 @@ object PickledQuotes {
7676
}
7777

7878
/** Unpickle the tree contained in the TastyType */
79-
def unpickleType(tasty: PickledQuote, args: PickledTypeArgs)(implicit ctx: Context): Tree = {
79+
def unpickleType(tasty: PickledQuote, args: PickledArgs)(implicit ctx: Context): Tree = {
8080
val tastyBytes = TastyString.unpickle(tasty)
8181
val unpickled = unpickle(tastyBytes, args, isType = true)(ctx.addMode(Mode.ReadPositions))
8282
val tpt = unpickled match {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
3535
// QUOTE UNPICKLING //
3636
//////////////////////
3737

38-
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): scala.quoted.Expr[?] =
38+
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledArgs): scala.quoted.Expr[?] =
3939
new TastyTreeExpr(PickledQuotes.unpickleExpr(repr, args), compilerId)
4040

41-
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): scala.quoted.Type[?] =
41+
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledArgs): scala.quoted.Type[?] =
4242
new TreeType(PickledQuotes.unpickleType(repr, args), compilerId)
4343

4444

@@ -67,7 +67,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
6767
def Context_requiredMethod(self: Context)(path: String): Symbol = self.requiredMethod(path)
6868
def Context_isJavaCompilationUnit(self: Context): Boolean = self.compilationUnit.isInstanceOf[fromtasty.JavaCompilationUnit]
6969
def Context_isScala2CompilationUnit(self: Context): Boolean = self.compilationUnit.isInstanceOf[fromtasty.Scala2CompilationUnit]
70-
def Context_compilationUnitClassname(self: Context): String =
70+
def Context_compilationUnitClassname(self: Context): String =
7171
self.compilationUnit match {
7272
case cu: fromtasty.JavaCompilationUnit => cu.className
7373
case cu: fromtasty.Scala2CompilationUnit => cu.className

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,8 @@ class ReifyQuotes extends MacroTransform {
230230
val meth =
231231
if (isType) ref(defn.Unpickler_unpickleType).appliedToType(originalTp)
232232
else ref(defn.Unpickler_unpickleExpr).appliedToType(originalTp.widen)
233-
val spliceResType =
234-
if (isType) defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)
235-
else defn.AnyType // defn.FunctionType(1, isContextual = true).appliedTo(defn.QuoteContextClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(defn.AnyType)) | defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)
236233
val pickledQuoteStrings = liftList(PickledQuotes.pickleQuote(body).map(x => Literal(Constant(x))), defn.StringType)
237-
val splicesList = liftList(splices, defn.FunctionType(1).appliedTo(defn.SeqType.appliedTo(defn.AnyType), spliceResType))
234+
val splicesList = liftList(splices, defn.FunctionType(1).appliedTo(defn.SeqType.appliedTo(defn.AnyType), defn.AnyType))
238235
meth.appliedTo(pickledQuoteStrings, splicesList)
239236
}
240237

library/src/scala/internal/quoted/Unpickler.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@ import scala.quoted.{Expr, QuoteContext, Type}
66
object Unpickler {
77

88
type PickledQuote = List[String]
9-
type PickledExprArgs = Seq[Seq[Any] => Any]
10-
type PickledTypeArgs = Seq[Seq[Any] => Type[_]]
9+
type PickledArgs = Seq[Seq[Any] => Any/*(([QCtx <: QuoteContext] =>> QCtx ?=> Expr[Any]) | Type[_])*/]
1110

1211
/** Unpickle `repr` which represents a pickled `Expr` tree,
1312
* replacing splice nodes with `args`
1413
*/
15-
def unpickleExpr[T](repr: PickledQuote, args: PickledExprArgs): QuoteContext ?=> Expr[T] =
14+
def unpickleExpr[T](repr: PickledQuote, args: PickledArgs): QuoteContext ?=> Expr[T] =
1615
summon[QuoteContext].tasty.internal.unpickleExpr(repr, args).asInstanceOf[Expr[T]]
1716

1817
/** Unpickle `repr` which represents a pickled `Type` tree,
1918
* replacing splice nodes with `args`
2019
*/
21-
def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): QuoteContext ?=> Type[T] =
20+
def unpickleType[T](repr: PickledQuote, args: PickledArgs): QuoteContext ?=> Type[T] =
2221
summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]]
2322

2423
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ trait CompilerInterface {
125125
/** Unpickle `repr` which represents a pickled `Expr` tree,
126126
* replacing splice nodes with `args`
127127
*/
128-
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): scala.quoted.Expr[_]
128+
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledArgs): scala.quoted.Expr[_]
129129

130130
/** Unpickle `repr` which represents a pickled `Type` tree,
131131
* replacing splice nodes with `args`
132132
*/
133-
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): scala.quoted.Type[_]
133+
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledArgs): scala.quoted.Type[_]
134134

135135

136136
/////////////

0 commit comments

Comments
 (0)