Skip to content

Commit 83d4f82

Browse files
committed
Remove dead code in FirstTransform
1 parent 0353e64 commit 83d4f82

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

compiler/src/dotty/tools/dotc/transform/FirstTransform.scala

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
7575
}
7676
}
7777

78-
/** Reorder statements so that module classes always come after their companion classes, add missing companion classes */
78+
/** Reorder statements so that module classes always come after their companion classes */
7979
private def reorderAndComplete(stats: List[Tree])(implicit ctx: Context): List[Tree] = {
8080
val moduleClassDefs, singleClassDefs = mutable.Map[Name, Tree]()
8181

@@ -108,39 +108,7 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
108108
case Nil => revPrefix.reverse
109109
}
110110

111-
def registerCompanion(name: TermName, forClass: Symbol): TermSymbol = {
112-
val (modul, mcCompanion, classCompanion) = newCompanion(name, forClass)
113-
if (ctx.owner.isClass) modul.enteredAfter(thisPhase)
114-
mcCompanion.enteredAfter(thisPhase)
115-
classCompanion.enteredAfter(thisPhase)
116-
modul
117-
}
118-
119-
def addMissingCompanions(stats: List[Tree]): List[Tree] = stats map {
120-
case stat: TypeDef if (singleClassDefs contains stat.name) && needsCompanion(stat.symbol.asClass) =>
121-
val objName = stat.name.toTermName
122-
val nameClash = stats.exists {
123-
case other: MemberDef =>
124-
other.name == objName && other.symbol.info.isParameterless
125-
case _ =>
126-
false
127-
}
128-
val uniqueName = if (nameClash) AvoidClashName(objName) else objName
129-
Thicket(stat :: ModuleDef(registerCompanion(uniqueName, stat.symbol), Nil).trees)
130-
case stat => stat
131-
}
132-
133-
addMissingCompanions(reorder(stats, Nil))
134-
}
135-
136-
private def newCompanion(name: TermName, forClass: Symbol)(implicit ctx: Context) = {
137-
val modul = ctx.newCompleteModuleSymbol(forClass.owner, name, Synthetic, Synthetic,
138-
defn.ObjectType :: Nil, Scopes.newScope, assocFile = forClass.asClass.assocFile)
139-
val mc = modul.moduleClass
140-
141-
val mcComp = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, forClass, mc)
142-
val classComp = ctx.synthesizeCompanionMethod(nme.COMPANION_MODULE_METHOD, mc, forClass)
143-
(modul, mcComp, classComp)
111+
reorder(stats, Nil)
144112
}
145113

146114
/** elimiate self in Template */

0 commit comments

Comments
 (0)