@@ -232,6 +232,7 @@ object desugar {
232
232
def classDef (cdef : TypeDef )(implicit ctx : Context ): Tree = {
233
233
val TypeDef (name, impl @ Template (constr0, parents, self, _)) = cdef
234
234
val mods = cdef.mods
235
+ val accessFlags = (mods.flags & AccessFlags ).toCommonFlags
235
236
236
237
val (constr1, defaultGetters) = defDef(constr0, isPrimaryConstructor = true ) match {
237
238
case meth : DefDef => (meth, Nil )
@@ -312,6 +313,7 @@ object desugar {
312
313
case ValDef (_, tpt, _) => isRepeated(tpt)
313
314
case _ => false
314
315
})
316
+
315
317
val copyMeths =
316
318
if (mods.is(Abstract ) || hasRepeatedParam) Nil // cannot have default arguments for repeated parameters, hence copy method is not issued
317
319
else {
@@ -346,7 +348,7 @@ object desugar {
346
348
moduleDef(
347
349
ModuleDef (
348
350
name.toTermName, Template (emptyConstructor, parentTpt :: Nil , EmptyValDef , defs))
349
- .withMods(synthetic ))
351
+ .withFlags( Synthetic | accessFlags ))
350
352
.withPos(cdef.pos).toList
351
353
352
354
// The companion object definitions, if a companion is needed, Nil otherwise.
@@ -371,7 +373,7 @@ object desugar {
371
373
if (mods is Abstract ) Nil
372
374
else
373
375
DefDef (nme.apply, derivedTparams, derivedVparamss, TypeTree (), creatorExpr)
374
- .withMods(synthetic | (constr1.mods.flags & DefaultParameterized )) :: Nil
376
+ .withFlags( Synthetic | (constr1.mods.flags & DefaultParameterized )) :: Nil
375
377
val unapplyMeth = {
376
378
val unapplyParam = makeSyntheticParameter(tpt = classTypeRef)
377
379
val unapplyRHS = if (arity == 0 ) Literal (Constant (true )) else Ident (unapplyParam.name)
@@ -403,7 +405,7 @@ object desugar {
403
405
// implicit wrapper is typechecked in same scope as constructor, so
404
406
// we can reuse the constructor parameters; no derived params are needed.
405
407
DefDef (name.toTermName, constrTparams, constrVparamss, classTypeRef, creatorExpr)
406
- .withFlags(Synthetic | Implicit )
408
+ .withFlags(Synthetic | Implicit | accessFlags )
407
409
.withPos(cdef.pos) :: Nil
408
410
409
411
@@ -453,7 +455,7 @@ object desugar {
453
455
val clsName = name.moduleClassName
454
456
val clsRef = Ident (clsName)
455
457
val modul = ValDef (name, clsRef, New (clsRef, Nil ))
456
- .withMods(mods | ModuleCreationFlags )
458
+ .withMods(mods | ModuleCreationFlags | mods.flags & AccessFlags )
457
459
.withPos(mdef.pos)
458
460
val ValDef (selfName, selfTpt, _) = tmpl.self
459
461
val selfMods = tmpl.self.mods
@@ -515,7 +517,7 @@ object desugar {
515
517
derivedValDef(named, tpt, matchExpr, mods)
516
518
case _ =>
517
519
val tmpName = ctx.freshName().toTermName
518
- val patFlags = PrivateLocal | Synthetic | (mods.flags & Lazy )
520
+ val patFlags = mods.flags & AccessFlags | Synthetic | (mods.flags & Lazy )
519
521
val firstDef = ValDef (tmpName, TypeTree (), matchExpr).withFlags(patFlags)
520
522
def selector (n : Int ) = Select (Ident (tmpName), nme.selectorName(n))
521
523
val restDefs =
0 commit comments