From f732e88f18bf53787ba6850bb62b279e1166a96b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 3 Nov 2020 10:24:18 +0100 Subject: [PATCH] Fix #10143: Handle shared package references --- .../dotc/core/tasty/TastyClassName.scala | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyClassName.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyClassName.scala index 12e8a60c5a28..c4283bb43473 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyClassName.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyClassName.scala @@ -25,10 +25,6 @@ class TastyClassName(bytes: Array[Byte]) { import dotty.tools.tasty.TastyFormat._ def unpickle(reader: TastyReader, tastyName: NameTable): (TermName, TermName) = { import reader._ - def readName() = { - val idx = readNat() - nameAtRef(NameRef(idx)) - } def readNames(packageName: TermName): (TermName, TermName) = { val tag = readByte() if (tag >= firstLengthTreeTag) { @@ -36,7 +32,7 @@ class TastyClassName(bytes: Array[Byte]) { val end = currentAddr + len tag match { case TYPEDEF => - val className = readName() + val className = reader.readName() goto(end) (packageName, className) case IMPORT | VALDEF => @@ -48,7 +44,14 @@ class TastyClassName(bytes: Array[Byte]) { } else tag match { case TERMREFpkg | TYPEREFpkg => - val subPackageName = readName() + val subPackageName = reader.readName() + readNames(subPackageName) + case SHAREDtype => + val addr = reader.readAddr() + val reader2 = reader.subReader(addr, reader.endAddr) + val tag2 = reader2.readByte() + assert(tag2 == TERMREFpkg || tag2 == TYPEREFpkg) + val subPackageName = reader2.readName() readNames(subPackageName) case _ => readNames(packageName) @@ -56,5 +59,11 @@ class TastyClassName(bytes: Array[Byte]) { } readNames(nme.EMPTY_PACKAGE) } + + extension (reader: TastyReader) def readName() = { + val idx = reader.readNat() + nameAtRef(NameRef(idx)) + } } + }