Skip to content

Commit 6a89a88

Browse files
committed
wip
1 parent 38f0b57 commit 6a89a88

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ object PickledQuotes {
9898

9999
/** Pickle tree into it's TASTY bytes s*/
100100
private def pickle(tree: Tree)(implicit ctx: Context): Array[Byte] = {
101+
// println("+++++++++++++++++++++++++++++++")
102+
// println(tree.show)
103+
// println(tree)
104+
// println()
105+
// println()
106+
// println()
101107
val pickler = new TastyPickler(defn.RootClass)
102108
val treePkl = pickler.treePkl
103109
treePkl.pickle(tree :: Nil)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,19 @@ class TreePickler(pickler: TastyPickler) {
599599
pickleTree(alias)
600600
}
601601
case Hole(_, idx, args) =>
602+
lazy val erasedSplicesType = new TypeMap() {
603+
override def apply(tp: Type): Type = tp match {
604+
case tp: TypeRef if tp.typeSymbol.isSplice || tp.typeSymbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) => tp.dealias.typeSymbol.info.hiBound
605+
case tp =>
606+
mapOver(tp)
607+
}
608+
}
609+
val tpe = erasedSplicesType(tree.tpe)
610+
602611
writeByte(HOLE)
603612
withLength {
604613
writeNat(idx)
614+
pickleType(tpe)
605615
args.foreach(pickleTree)
606616
}
607617
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,14 @@ class TreeUnpickler(reader: TastyReader,
12921292

12931293
def readHole(end: Addr, isType: Boolean)(implicit ctx: Context): Tree = {
12941294
val idx = readNat()
1295+
val tpe = readType() // FIXME use to set type to the unpickled tree
12951296
val args = until(end)(readTerm())
12961297
val splice = splices(idx)
1298+
// println("++++++++++++++++++++++++++++++=")
1299+
// println(tpe.show)
1300+
// println(isType)
1301+
// println()
1302+
// println()
12971303
def wrap(arg: Tree) =
12981304
if (arg.isTerm) (qctx: scala.quoted.QuoteContext) ?=> new TastyTreeExpr(arg, QuoteContext.scopeId)
12991305
else new TreeType(arg, QuoteContext.scopeId)
@@ -1305,7 +1311,8 @@ class TreeUnpickler(reader: TastyReader,
13051311
else {
13061312
val splice1 = splice.asInstanceOf[Seq[Any] => scala.quoted.QuoteContext ?=> quoted.Expr[?]]
13071313
val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContext())
1308-
PickledQuotes.quotedExprToTree(quotedExpr)
1314+
val a = PickledQuotes.quotedExprToTree(quotedExpr)
1315+
a.ensureConforms(tpe).withSpan(a.span)
13091316
}
13101317
// We need to make sure a hole is created with the source file of the surrounding context, even if
13111318
// it filled with contents a different source file. Otherwise nodes containing holes might end

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ Standard Section: "Comments" Comment*
254254
object TastyFormat {
255255

256256
final val header: Array[Int] = Array(0x5C, 0xA1, 0xAB, 0x1F)
257-
val MajorVersion: Int = 20
257+
val MajorVersion: Int = 21
258258
val MinorVersion: Int = 0
259259

260260
/** Tags used to serialize names, should update [[nameTagToString]] if a new constant is added */

tests/pos-macros/i7110/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22

33
object Macros {
44

5-
inline def m[R](sym: Symantics[R]) : R = ${ mImpl[R]('{sym}) }
5+
// inline def m[R](sym: Symantics[R]) : R = ${ mImpl[R]('{sym}) }
66

77
def mImpl[R: Type](using qctx: QuoteContext)(sym: Expr[Symantics[R]]): Expr[R] = '{
88
$sym.Meth(42)

0 commit comments

Comments
 (0)