From 800b1ad042044d8902c76fe353f7adf0491b5f20 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 6 Apr 2017 15:34:09 +0200 Subject: Fix pickling/unpickling of names Running the test suite with the pickling printer on showed up two more problems which are fixed in this commit. --- compiler/src/dotty/tools/dotc/core/NameKinds.scala | 7 +++++++ compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala | 6 +++--- compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala index c34a100a8..bee39adaa 100644 --- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala +++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala @@ -141,6 +141,13 @@ object NameKinds { } } + object AnyNumberedName { + def unapply(name: DerivedTermName): Option[(TermName, Int)] = name match { + case DerivedTermName(qual, info: NumberedInfo) => Some((qual, info.num)) + case _ => None + } + } + case class UniqueNameKind(val separator: String) extends NumberedNameKind(UNIQUE, s"Unique $separator") { override def definesNewName = true diff --git a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala index 7ee6427f3..270d6be56 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala @@ -45,7 +45,7 @@ class NameBuffer extends TastyBuffer(10000) { val lengthAddr = currentAddr for (i <- 0 until lengthWidth) writeByte(0) op - val length = currentAddr.index - lengthAddr.index - 1 + val length = currentAddr.index - lengthAddr.index - lengthWidth putNat(lengthAddr, length, lengthWidth) } @@ -70,10 +70,10 @@ class NameBuffer extends TastyBuffer(10000) { writeNat(num) if (!original.isEmpty) writeNameRef(original) } - case DefaultGetterName(method, paramNumber) => - withLength { writeNameRef(method); writeNat(paramNumber) } case VariantName(original, sign) => withLength { writeNameRef(original); writeNat(sign + 1) } + case AnyNumberedName(original, num) => + withLength { writeNameRef(original); writeNat(num) } case SignedName(original, Signature(params, result)) => withLength( { writeNameRef(original); writeNameRef(result); params.foreach(writeNameRef) }, diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala index 835222727..37a3c2e76 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala @@ -61,6 +61,8 @@ class TastyUnpickler(reader: TastyReader) { DefaultGetterName(readName(), readNat()) case VARIANT => VariantName(readName(), readNat() - 1) + case OUTERSELECT => + OuterSelectName(readName(), readNat()) case SIGNED => val original = readName() val result = readName().toTypeName -- cgit v1.2.3