Skip to content

Commit

Permalink
Merge pull request scala#956 from dotty-staging/companion-methods
Browse files Browse the repository at this point in the history
Remove duplication of companion methods in Scala2Unpickler
  • Loading branch information
DarkDimius committed Nov 16, 2015
2 parents 522c1f2 + a369a81 commit 08b5324
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ object Scala2Unpickler {
val scalacCompanion = denot.classSymbol.scalacLinkedClass

def registerCompanionPair(module: Symbol, claz: Symbol) = {
val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, claz, module)
if (companionClassMethod.exists)
companionClassMethod.entered
def registerCompanionMethod(name: Name, target: Symbol, owner: Symbol) = {
if (!owner.unforcedDecls.lookup(name).exists) {
val companionMethod = ctx.synthesizeCompanionMethod(name, target, owner)
if (companionMethod.exists) {
companionMethod.entered
}
}
}
registerCompanionMethod(nme.COMPANION_CLASS_METHOD, claz, module)
if (claz.isClass) {
val companionModuleMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_MODULE_METHOD, module, claz)
if (companionModuleMethod.exists)
companionModuleMethod.entered
registerCompanionMethod(nme.COMPANION_MODULE_METHOD, module, claz)
}
}

Expand Down

0 comments on commit 08b5324

Please sign in to comment.