Skip to content

Commit 812d22d

Browse files
committed
Two fixes to pickling and unpickling of untyped trees
- Fix pickling of untyped templates - Fix unpickling of TypeBoundsTrees
1 parent 8fe1a0e commit 812d22d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -798,12 +798,14 @@ class TreePickler(pickler: TastyPickler) {
798798
pickleDef(OBJECTDEF, tree, tree.impl)
799799
case tree: untpd.Template =>
800800
writeByte(TEMPLATE)
801-
tree.parents.foreach(pickleParent)
802-
if (!tree.self.isEmpty) {
803-
writeByte(SELFDEF); pickleName(tree.self.name); pickleTpt(tree.self.tpt)
801+
withLength {
802+
tree.parents.foreach(pickleParent)
803+
if (!tree.self.isEmpty) {
804+
writeByte(SELFDEF); pickleName(tree.self.name); pickleTpt(tree.self.tpt)
805+
}
806+
pickleUntyped(tree.constr)
807+
tree.body.foreach(pickleUntyped)
804808
}
805-
pickleUntyped(tree.constr)
806-
tree.body.foreach(pickleUntyped)
807809
case Import(expr, selectors) =>
808810
writeByte(IMPORT)
809811
withLength { pickleUntyped(expr); pickleSelectors(selectors) }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ class TreeUnpickler(reader: TastyReader,
13651365
untpd.LambdaTypeTree(tparams, body)
13661366
case TYPEBOUNDStpt =>
13671367
val lo = readUntyped()
1368-
val hi = ifBefore(end)(lo, readUntyped())
1368+
val hi = ifBefore(end)(readUntyped(), lo)
13691369
untpd.TypeBoundsTree(lo, hi)
13701370
case TYPEDSPLICE =>
13711371
untpd.TypedSplice(readTerm())

tests/pickling/transparent.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Foo {
2+
transparent def foo() = {
3+
abstract class C[T] extends Object {
4+
def x: T
5+
println(x)
6+
}
7+
()
8+
}
9+
}

0 commit comments

Comments
 (0)