diff options
author | VladimirNik <vladimir.nikolaev9@gmail.com> | 2015-11-25 14:13:12 +0100 |
---|---|---|
committer | VladimirNik <vladimir.nikolaev9@gmail.com> | 2015-11-25 22:40:46 +0100 |
commit | 0afb2a357e1cdf0184af6570483d739b5fe84f3e (patch) | |
tree | 68d56c413b82f6eb4f2a280d5460a665434def9e | |
parent | 7ce2b3bec6c243658823f48032dce28064feeb98 (diff) | |
download | dotty-0afb2a357e1cdf0184af6570483d739b5fe84f3e.tar.gz dotty-0afb2a357e1cdf0184af6570483d739b5fe84f3e.tar.bz2 dotty-0afb2a357e1cdf0184af6570483d739b5fe84f3e.zip |
Duplication of companion methods after using FromTasty fixed
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 426a6804b..71f51d9a1 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -41,12 +41,18 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { } private val symAtAddr = new mutable.HashMap[Addr, Symbol] + private val unpickledSyms = new mutable.HashSet[Symbol] private val treeAtAddr = new mutable.HashMap[Addr, Tree] private val typeAtAddr = new mutable.HashMap[Addr, Type] // currently populated only for types that are known to be SHAREd. private var stubs: Set[Symbol] = Set() private var roots: Set[SymDenotation] = null + private def registerSym(addr: Addr, sym: Symbol) = { + symAtAddr(addr) = sym + unpickledSyms += sym + } + /** Enter all toplevel classes and objects into their scopes * @param roots a set of SymDenotations that should be overwritten by unpickling */ @@ -206,7 +212,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { OrType(readType(), readType()) case BIND => val sym = ctx.newSymbol(ctx.owner, readName().toTypeName, BindDefinedType, readType()) - symAtAddr(start) = sym + registerSym(start, sym) TypeRef.withFixedSym(NoPrefix, sym.name, sym) case POLYtype => val (names, paramReader) = readNamesSkipParams[TypeName] @@ -404,7 +410,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { } // TODO set position sym.annotations = annots ctx.enter(sym) - symAtAddr(start) = sym + registerSym(start, sym) if (isClass) { sym.completer.withDecls(newScope) forkAt(templateStart).indexTemplateParams()(localContext(sym)) @@ -590,7 +596,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { case TYPEDEF | TYPEPARAM => if (sym.isClass) { val companion = sym.scalacLinkedClass - if (companion != NoSymbol) { + if (companion != NoSymbol && unpickledSyms.contains(companion)) { import transform.SymUtils._ if (sym is Flags.ModuleClass) sym.registerCompanionMethod(nme.COMPANION_CLASS_METHOD, companion) else sym.registerCompanionMethod(nme.COMPANION_MODULE_METHOD, companion) @@ -809,7 +815,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { val name = readName() val info = readType() val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, info) - symAtAddr(start) = sym + registerSym(start, sym) Bind(sym, readTerm()) case ALTERNATIVE => Alternative(until(end)(readTerm())) |