From 018118d41e27ba00f28a2f8ab4dbc62233ffb4f3 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 7 Jun 2017 16:43:41 +0200 Subject: [PATCH] Fix #2680: Backend generates useless companion class for inner objects `isTopLevelModuleClass` was incorrect and returned true for all static module classes. --- .../src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 709ce4616f9b..942c3f1fc071 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -746,7 +746,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma * True for module classes of package level objects. The backend will generate a mirror class for * such objects. */ - def isTopLevelModuleClass: Boolean = sym.isModuleClass && sym.isStatic + def isTopLevelModuleClass: Boolean = sym.isModuleClass && + ctx.atPhase(ctx.flattenPhase) { implicit ctx => + toDenot(sym).owner.is(Flags.PackageClass) + } /** * This is basically a re-implementation of sym.isStaticOwner, but using the originalOwner chain.