Skip to content

Commit f732e88

Browse files
committed
Fix scala#10143: Handle shared package references
1 parent 0bd50d3 commit f732e88

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ class TastyClassName(bytes: Array[Byte]) {
2525
import dotty.tools.tasty.TastyFormat._
2626
def unpickle(reader: TastyReader, tastyName: NameTable): (TermName, TermName) = {
2727
import reader._
28-
def readName() = {
29-
val idx = readNat()
30-
nameAtRef(NameRef(idx))
31-
}
3228
def readNames(packageName: TermName): (TermName, TermName) = {
3329
val tag = readByte()
3430
if (tag >= firstLengthTreeTag) {
3531
val len = readNat()
3632
val end = currentAddr + len
3733
tag match {
3834
case TYPEDEF =>
39-
val className = readName()
35+
val className = reader.readName()
4036
goto(end)
4137
(packageName, className)
4238
case IMPORT | VALDEF =>
@@ -48,13 +44,26 @@ class TastyClassName(bytes: Array[Byte]) {
4844
}
4945
else tag match {
5046
case TERMREFpkg | TYPEREFpkg =>
51-
val subPackageName = readName()
47+
val subPackageName = reader.readName()
48+
readNames(subPackageName)
49+
case SHAREDtype =>
50+
val addr = reader.readAddr()
51+
val reader2 = reader.subReader(addr, reader.endAddr)
52+
val tag2 = reader2.readByte()
53+
assert(tag2 == TERMREFpkg || tag2 == TYPEREFpkg)
54+
val subPackageName = reader2.readName()
5255
readNames(subPackageName)
5356
case _ =>
5457
readNames(packageName)
5558
}
5659
}
5760
readNames(nme.EMPTY_PACKAGE)
5861
}
62+
63+
extension (reader: TastyReader) def readName() = {
64+
val idx = reader.readNat()
65+
nameAtRef(NameRef(idx))
66+
}
5967
}
68+
6069
}

0 commit comments

Comments
 (0)