Skip to content

Commit 018118d

Browse files
committed
Fix #2680: Backend generates useless companion class for inner objects
`isTopLevelModuleClass` was incorrect and returned true for all static module classes.
1 parent 6f8bc43 commit 018118d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
746746
* True for module classes of package level objects. The backend will generate a mirror class for
747747
* such objects.
748748
*/
749-
def isTopLevelModuleClass: Boolean = sym.isModuleClass && sym.isStatic
749+
def isTopLevelModuleClass: Boolean = sym.isModuleClass &&
750+
ctx.atPhase(ctx.flattenPhase) { implicit ctx =>
751+
toDenot(sym).owner.is(Flags.PackageClass)
752+
}
750753

751754
/**
752755
* This is basically a re-implementation of sym.isStaticOwner, but using the originalOwner chain.

0 commit comments

Comments
 (0)