diff options
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 2 | ||||
-rw-r--r-- | src/scala/Product0.scala | 24 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index c3d0f9c3a..671fbef51 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -312,12 +312,12 @@ object desugar { def productConstr(n: Int) = { val tycon = ref(defn.ProductNClass(n).typeRef) val targs = constrVparamss.head map (_.tpt) - AppliedTypeTree(tycon, targs) + if (targs.isEmpty) tycon else AppliedTypeTree(tycon, targs) } // Case classes get a ProductN parent var parents1 = parents - if ((mods is Case) && 2 <= arity && arity <= Definitions.MaxTupleArity) + if ((mods is Case) && arity <= Definitions.MaxTupleArity) parents1 = parents1 :+ productConstr(arity) // The thicket which is the desugared version of the companion object diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index ac179ca9e..e1808b181 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -394,7 +394,7 @@ class Definitions { lazy val Function0_apply = FunctionClass(0).requiredMethod(nme.apply) lazy val TupleClass = mkArityArray("scala.Tuple", MaxTupleArity, 2) - lazy val ProductNClass = mkArityArray("scala.Product", MaxTupleArity, 2) + lazy val ProductNClass = mkArityArray("scala.Product", MaxTupleArity, 0) lazy val FunctionClasses: Set[Symbol] = FunctionClass.toSet lazy val TupleClasses: Set[Symbol] = TupleClass.toSet diff --git a/src/scala/Product0.scala b/src/scala/Product0.scala new file mode 100644 index 000000000..23e7e52c0 --- /dev/null +++ b/src/scala/Product0.scala @@ -0,0 +1,24 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala + +/** A class for Product0 which was missing from the scala distribution. */ +object Product0 { + def unapply(x: Product0): Option[Product0] = + Some(x) +} + +trait Product0 extends Any with Product { + + override def productArity = 0 + + @throws(classOf[IndexOutOfBoundsException]) + override def productElement(n: Int) = + throw new IndexOutOfBoundsException(n.toString()) +} + |