diff options
author | Martin Odersky <odersky@gmail.com> | 2015-04-06 10:45:41 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-04-07 23:53:58 +0200 |
commit | 300fad54d986d6e654961cf703fc9a8f5d8b3233 (patch) | |
tree | 7c580ac761c1409c456a8af92fc541200f02dca5 /src | |
parent | 131054b6f3c380b1c14ece54b725b3e9d9eeaf55 (diff) | |
download | dotty-300fad54d986d6e654961cf703fc9a8f5d8b3233.tar.gz dotty-300fad54d986d6e654961cf703fc9a8f5d8b3233.tar.bz2 dotty-300fad54d986d6e654961cf703fc9a8f5d8b3233.zip |
Move normalizeClassRef to readTemplate
Do a normalizeClassRef immediately after parents are read. Not clear
whether this chanegs anything, but it's the prudent thing to do since
Namer behaves the same way.
The danger would be that between reading parents and normalizing refs
someone refers to an overridden param and gets the wrong type.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala index 22f6fc7e7..cea29ce80 100644 --- a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala @@ -570,17 +570,8 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { sym.info = readType() ValDef(sym.asTerm, readRhs(localCtx)) case TYPEDEF | TYPEPARAM => - if (sym.isClass) { - val cls = sym.asClass - def setClsInfo(parents: List[TypeRef], selfType: Type) = - cls.info = ClassInfo(cls.owner.thisType, cls, parents, cls.unforcedDecls, selfType) - setClsInfo(Nil, NoType) - val impl = readTemplate(localCtx) - setClsInfo( - ctx.normalizeToClassRefs(impl.parents.map(_.tpe), cls, cls.unforcedDecls), - if (impl.self.isEmpty) NoType else impl.self.tpt.tpe) - ta.assignType(untpd.TypeDef(sym.name.asTypeName, impl), sym) - } + if (sym.isClass) + ta.assignType(untpd.TypeDef(sym.name.asTypeName, readTemplate(localCtx)), sym) else { sym.info = readType() TypeDef(sym.asType) @@ -609,6 +600,9 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { private def readTemplate(implicit ctx: Context): Template = { val start = currentAddr val cls = ctx.owner.asClass + def setClsInfo(parents: List[TypeRef], selfType: Type) = + cls.info = ClassInfo(cls.owner.thisType, cls, parents, cls.unforcedDecls, selfType) + setClsInfo(Nil, NoType) val localDummy = ctx.newLocalDummy(cls) assert(readByte() == TEMPLATE) val end = readEnd() @@ -620,12 +614,14 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { case _ => readTpt() } } - val self = + val parentRefs = ctx.normalizeToClassRefs(parents.map(_.tpe), cls, cls.unforcedDecls) + val self = if (nextByte == SELFDEF) { readByte() untpd.ValDef(readName(), readTpt(), EmptyTree).withType(NoType) } else EmptyValDef + setClsInfo(parentRefs, if (self.isEmpty) NoType else self.tpt.tpe) val noInits = fork.indexStats(end) if (noInits) cls.setFlag(NoInits) val constr = readIndexedDef().asInstanceOf[DefDef] |