@@ -325,26 +325,29 @@ private[dataclass] class Macros(val c: Context) extends ImplTransformers {
325325 val q " $mmods object $mname extends { .. $mearlydefns } with .. $mparents { $mself => .. $mstats } " =
326326 mdef
327327
328- val applyMethods = splits.map { idx =>
329- val (a, b) = paramss.head.splitAt(idx)
330- val a0 = a.map {
331- case ValDef (mods, name, tpt, _) =>
332- q " $name: $tpt"
333- }
334- // Weirdly enough, things compile fine without this check (resulting in empty trees hanging around)
335- b.foreach { p =>
336- if (p.rhs.isEmpty)
337- c.abort(
338- p.pos,
339- s " Found parameter with no default value ${p.name} after @since annotation "
340- )
341- }
342- val a1 = a0 :: paramss.tail
343- q """ def apply[.. $tparams](... $a1): $tpname[.. $tparamsRef] = new $tpname[.. $tparamsRef](... ${(a
344- .map(p => q " ${p.name}" ) ++ b.map(_.rhs)) :: paramss.tail.map(
345- _.map(p => q " ${p.name}" )
346- )}) """
347- }
328+ val applyMethods =
329+ if (ctorMods.hasFlag(Flag .PRIVATE )) Nil
330+ else
331+ splits.map { idx =>
332+ val (a, b) = paramss.head.splitAt(idx)
333+ val a0 = a.map {
334+ case ValDef (mods, name, tpt, _) =>
335+ q " $name: $tpt"
336+ }
337+ // Weirdly enough, things compile fine without this check (resulting in empty trees hanging around)
338+ b.foreach { p =>
339+ if (p.rhs.isEmpty)
340+ c.abort(
341+ p.pos,
342+ s " Found parameter with no default value ${p.name} after @since annotation "
343+ )
344+ }
345+ val a1 = a0 :: paramss.tail
346+ q """ def apply[.. $tparams](... $a1): $tpname[.. $tparamsRef] = new $tpname[.. $tparamsRef](... ${(a
347+ .map(p => q " ${p.name}" ) ++ b.map(_.rhs)) :: paramss.tail.map(
348+ _.map(p => q " ${p.name}" )
349+ )}) """
350+ }
348351
349352 val mdef0 =
350353 q " $mmods object $mname extends { .. $mearlydefns } with .. $mparents { $mself => .. $mstats; .. $applyMethods } "
0 commit comments