@@ -228,7 +228,7 @@ object desugar {
228
228
val tparam = cpy.TypeDef (tdef)(name = tdef.name.expandedName(ctx.owner))
229
229
.withMods(tdef.mods &~ PrivateLocal | ExpandedName )
230
230
val alias = cpy.TypeDef (tdef)(rhs = refOfDef(tparam), tparams = Nil )
231
- .withFlags( PrivateLocalParamAccessor | Synthetic | tdef.mods.flags & VarianceFlags )
231
+ .withMods( tdef.mods & VarianceFlags | PrivateLocalParamAccessor | Synthetic )
232
232
Thicket (tparam, alias)
233
233
}
234
234
else tdef
@@ -237,15 +237,15 @@ object desugar {
237
237
@ sharable private val synthetic = Modifiers (Synthetic )
238
238
239
239
private def toDefParam (tparam : TypeDef ): TypeDef =
240
- tparam.withFlags( Param )
240
+ tparam.withMods(tparam.rawMods & EmptyFlags | Param )
241
241
private def toDefParam (vparam : ValDef ): ValDef =
242
- vparam.withFlags( Param | vparam.rawMods.flags & Implicit )
242
+ vparam.withMods( vparam.rawMods & Implicit | Param )
243
243
244
244
/** The expansion of a class definition. See inline comments for what is involved */
245
245
def classDef (cdef : TypeDef )(implicit ctx : Context ): Tree = {
246
246
val TypeDef (name, impl @ Template (constr0, parents, self, _)) = cdef
247
247
val mods = cdef.mods
248
- val accessFlags = ( mods.flags & AccessFlags ).toCommonFlags
248
+ val companionMods = mods.withFlags(( mods.flags & AccessFlags ).toCommonFlags)
249
249
250
250
val (constr1, defaultGetters) = defDef(constr0, isPrimaryConstructor = true ) match {
251
251
case meth : DefDef => (meth, Nil )
@@ -364,7 +364,7 @@ object desugar {
364
364
moduleDef(
365
365
ModuleDef (
366
366
name.toTermName, Template (emptyConstructor, parentTpt :: Nil , EmptyValDef , defs))
367
- .withFlags( Synthetic | accessFlags ))
367
+ .withMods(companionMods | Synthetic ))
368
368
.withPos(cdef.pos).toList
369
369
370
370
// The companion object definitions, if a companion is needed, Nil otherwise.
@@ -421,10 +421,9 @@ object desugar {
421
421
// implicit wrapper is typechecked in same scope as constructor, so
422
422
// we can reuse the constructor parameters; no derived params are needed.
423
423
DefDef (name.toTermName, constrTparams, constrVparamss, classTypeRef, creatorExpr)
424
- .withFlags( Synthetic | Implicit | accessFlags )
424
+ .withMods(companionMods | Synthetic | Implicit )
425
425
.withPos(cdef.pos) :: Nil
426
426
427
-
428
427
val self1 = {
429
428
val selfType = if (self.tpt.isEmpty) classTypeRef else self.tpt
430
429
if (self.isEmpty) self
0 commit comments