From 97b6985c34915b58e0c81fbab464f4bd532c27d0 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 11 Nov 2016 22:20:24 +0100 Subject: Clean up parameterized typedefs Express them in terms PolyTypeTrees rather than having an irregular, untyped only tparams field. This is necessary if we want to pickle type trees instead of types, because now the rhs of a typedef tells the whole story, so we are not required any longer to use the info of the symbol. --- src/dotty/tools/dotc/core/tasty/TreePickler.scala | 8 ++------ src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 5 ++++- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/dotty/tools/dotc/core') diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 9dfb78798..98a369f25 100644 --- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -49,10 +49,6 @@ class TreePickler(pickler: TastyPickler) { case None => } } - - def rhs(tdef: TypeDef)(implicit ctx: Context) = - if (tdef.symbol.isClass) tdef.rhs - else TypeTree(tdef.symbol.info).withPos(tdef.rhs.pos) private def pickleName(name: Name): Unit = writeNat(nameIndex(name).index) private def pickleName(name: TastyName): Unit = writeNat(nameIndex(name).index) @@ -336,7 +332,7 @@ class TreePickler(pickler: TastyPickler) { tree match { case tree: ValDef => pickleDef(PARAM, tree.symbol, tree.tpt) case tree: DefDef => pickleDef(PARAM, tree.symbol, tree.tpt, tree.rhs) - case tree: TypeDef => pickleDef(TYPEPARAM, tree.symbol, rhs(tree)) + case tree: TypeDef => pickleDef(TYPEPARAM, tree.symbol, tree.rhs) } } @@ -478,7 +474,7 @@ class TreePickler(pickler: TastyPickler) { } pickleDef(DEFDEF, tree.symbol, tree.tpt, tree.rhs, pickleAllParams) case tree: TypeDef => - pickleDef(TYPEDEF, tree.symbol, rhs(tree)) + pickleDef(TYPEDEF, tree.symbol, tree.rhs) case tree: Template => registerDef(tree.symbol) writeByte(TEMPLATE) diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index d2605afea..90f718402 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -696,7 +696,10 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle TypeDef(readTemplate(localCtx)) } else { val rhs = readTpt() - sym.info = rhs.tpe + sym.info = rhs.tpe match { + case _: TypeBounds | _: ClassInfo => rhs.tpe + case _ => TypeAlias(rhs.tpe, sym.variance) + } TypeDef(rhs) } case PARAM => -- cgit v1.2.3