@@ -75,7 +75,7 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
75
75
}
76
76
}
77
77
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 */
79
79
private def reorderAndComplete (stats : List [Tree ])(implicit ctx : Context ): List [Tree ] = {
80
80
val moduleClassDefs, singleClassDefs = mutable.Map [Name , Tree ]()
81
81
@@ -108,39 +108,7 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
108
108
case Nil => revPrefix.reverse
109
109
}
110
110
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 )
144
112
}
145
113
146
114
/** elimiate self in Template */
0 commit comments