Skip to content

Commit 6d2e9b3

Browse files
committed
Main sharing of TypeBoundsTree bounds through (un)pickling
1 parent b05c5d3 commit 6d2e9b3

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Standard-Section: "ASTs" TopLevelStat*
102102
REFINEDtpt Length underlying_Term refinement_Stat*
103103
APPLIEDtpt Length tycon_Term arg_Term*
104104
POLYtpt Length TypeParam* body_Term
105-
TYPEBOUNDStpt Length low_Term high_Term
105+
TYPEBOUNDStpt Length low_Term high_Term?
106106
ANNOTATEDtpt Length underlying_Term fullAnnotation_Term
107107
ANDtpt Length left_Term right_Term
108108
ORtpt Length left_Term right_Term

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,10 @@ class TreePickler(pickler: TastyPickler) {
552552
withLength { pickleParams(tparams); pickleTree(body) }
553553
case TypeBoundsTree(lo, hi) =>
554554
writeByte(TYPEBOUNDStpt)
555-
withLength { pickleTree(lo); pickleTree(hi) }
555+
withLength {
556+
pickleTree(lo);
557+
if (hi ne lo) pickleTree(hi)
558+
}
556559
case Hole(idx, args) =>
557560
writeByte(HOLE)
558561
withLength {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,9 @@ class TreeUnpickler(reader: TastyReader,
10381038
val body = readTpt()
10391039
LambdaTypeTree(tparams, body)
10401040
case TYPEBOUNDStpt =>
1041-
TypeBoundsTree(readTpt(), readTpt())
1041+
val lo = readTpt()
1042+
val hi = if (currentAddr == end) lo else readTpt()
1043+
TypeBoundsTree(lo, hi)
10421044
case HOLE =>
10431045
readHole(end)
10441046
case _ =>

0 commit comments

Comments
 (0)