Skip to content

Commit 72d91a3

Browse files
committed
All package refs should use TERMREFpkg for pickling
Previously, some references used TermRef and a name with signature, which gave two different ways to represent a package.
1 parent 5efd007 commit 72d91a3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/dotty/tools/dotc/core/pickling/TreePickler.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,11 @@ class TreePickler(pickler: TastyPickler) {
171171
else pickleRef()
172172
}
173173
case tpe: TermRefWithSignature =>
174-
writeByte(TERMREF)
175-
pickleNameAndSig(tpe.name, tpe.signature); pickleType(tpe.prefix)
174+
if (tpe.symbol.is(Flags.Package)) picklePackageRef(tpe.symbol)
175+
else {
176+
writeByte(TERMREF)
177+
pickleNameAndSig(tpe.name, tpe.signature); pickleType(tpe.prefix)
178+
}
176179
case tpe: NamedType =>
177180
if (tpe.name == tpnme.Apply && tpe.prefix.argInfos.nonEmpty && tpe.prefix.isInstantiatedLambda)
178181
// instantiated lambdas are pickled as APPLIEDTYPE; #Apply will
@@ -187,10 +190,8 @@ class TreePickler(pickler: TastyPickler) {
187190
pickleName(tpe.name); pickleType(tpe.prefix)
188191
}
189192
case tpe: ThisType =>
190-
if (tpe.cls.is(Flags.Package) && !tpe.cls.isEffectiveRoot) {
191-
writeByte(TERMREFpkg)
192-
pickleName(qualifiedName(tpe.cls))
193-
}
193+
if (tpe.cls.is(Flags.Package) && !tpe.cls.isEffectiveRoot)
194+
picklePackageRef(tpe.cls)
194195
else {
195196
writeByte(THIS)
196197
pickleType(tpe.tref)
@@ -259,6 +260,11 @@ class TreePickler(pickler: TastyPickler) {
259260
println(i"error while pickling type $tpe")
260261
throw ex
261262
}
263+
264+
def picklePackageRef(pkg: Symbol): Unit = {
265+
writeByte(TERMREFpkg)
266+
pickleName(qualifiedName(pkg))
267+
}
262268

263269
def pickleMethodic(result: Type, names: List[Name], types: List[Type]) =
264270
withLength {

0 commit comments

Comments
 (0)