Skip to content

Commit 70996f8

Browse files
committed
Added a -Yno-productN option.
Suppresses ProductN parent for case classes. No review.
1 parent 78db538 commit 70996f8

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ self =>
26872687
if (mods.isCase) {
26882688
val arity = if (vparamss.isEmpty || vparamss.head.isEmpty) 0 else vparamss.head.size
26892689
productConstr :: serializableConstr :: {
2690-
if (arity == 0) Nil
2690+
if (arity == 0 || settings.YnoProductN.value) Nil
26912691
else List(
26922692
AppliedTypeTree(
26932693
productConstrN(arity),

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ trait ScalaSettings extends AbsScalaSettings
175175
val YvirtClasses = false // too embryonic to even expose as a -Y //BooleanSetting ("-Yvirtual-classes", "Support virtual classes")
176176

177177
val exposeEmptyPackage = BooleanSetting("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
178+
val YnoProductN = BooleanSetting ("-Yno-productN", "Do not add ProductN to case classes")
178179

179180
def stop = stopAfter
180181

test/files/pos/noproductN.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Yno-productN

test/files/pos/noproductN.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
object Foo { type S = String }
2+
case class Foo(x: Foo.S) { }

0 commit comments

Comments
 (0)