Skip to content

Commit 5331db9

Browse files
authored
Merge pull request #2703 from dotty-staging/fix-useless-companion
Fix #2680: Backend generates useless companion class for inner objects
2 parents 6f8bc43 + 018118d commit 5331db9

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)