Skip to content

Commit ca30494

Browse files
committed
Make hole reading context-independent
Currently the translation of a hole depends on whether we are reading a type tree or a term tree, but that distinction is fickle.
1 parent 6be4781 commit ca30494

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class TreeUnpickler(reader: TastyReader,
350350
case binder: LambdaType => binder.paramRefs(readNat())
351351
}
352352
case HOLE =>
353-
readHole(end, isType = true).tpe
353+
readHole(end).tpe
354354
}
355355
assert(currentAddr == end, s"$start $currentAddr $end ${astTagToString(tag)}")
356356
result
@@ -1148,7 +1148,7 @@ class TreeUnpickler(reader: TastyReader,
11481148
val hi = if (currentAddr == end) lo else readTpt()
11491149
TypeBoundsTree(lo, hi)
11501150
case HOLE =>
1151-
readHole(end, isType = false)
1151+
readHole(end)
11521152
case UNTYPEDSPLICE =>
11531153
tpd.UntypedSplice(readUntyped()).withType(readType())
11541154
case _ =>
@@ -1204,20 +1204,17 @@ class TreeUnpickler(reader: TastyReader,
12041204
owner => new LazyReader(localReader, owner, ctx.mode, op)
12051205
}
12061206

1207-
def readHole(end: Addr, isType: Boolean)(implicit ctx: Context): Tree = {
1207+
def readHole(end: Addr)(implicit ctx: Context): Tree = {
12081208
val idx = readNat()
12091209
val args = until(end)(readTerm())
12101210
val splice = splices(idx)
12111211
def wrap(arg: Tree) =
12121212
if (arg.isTerm) new TastyTreeExpr(arg)
12131213
else new TreeType(arg)
12141214
val reifiedArgs = args.map(wrap)
1215-
if (isType) {
1216-
val quotedType = splice.asInstanceOf[Seq[Any] => quoted.Type[_]](reifiedArgs)
1217-
PickledQuotes.quotedTypeToTree(quotedType)
1218-
} else {
1219-
val quotedExpr = splice.asInstanceOf[Seq[Any] => quoted.Expr[_]](reifiedArgs)
1220-
PickledQuotes.quotedExprToTree(quotedExpr)
1215+
splice.asInstanceOf[Seq[Any] => Any](reifiedArgs) match {
1216+
case spliced: quoted.Type[_] => PickledQuotes.quotedTypeToTree(spliced)
1217+
case spliced: quoted.Expr[_] => PickledQuotes.quotedExprToTree(spliced)
12211218
}
12221219
}
12231220
// ------ Reading untyped trees --------------------------------------------

0 commit comments

Comments
 (0)