diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-10 17:51:02 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-10 18:34:59 +0200 |
commit | f606a47894271540bc7b21eb8c7b5d85bd560f57 (patch) | |
tree | ffe5f5b218d9ac8018974dab6ac24dd0a3332675 /src/dotty/tools/dotc/ast/Desugar.scala | |
parent | c2cdd3a3dca2a629923327046b213addd93499fc (diff) | |
download | dotty-f606a47894271540bc7b21eb8c7b5d85bd560f57.tar.gz dotty-f606a47894271540bc7b21eb8c7b5d85bd560f57.tar.bz2 dotty-f606a47894271540bc7b21eb8c7b5d85bd560f57.zip |
Add Product{1,2} supertrait to case classes
Case classes with arity <= 1 now also get a ProductN parent trait.
This is necessary because we inherit productArity and Element methods
in case classes from the ProdictN trait.
Needed to add Product0 for this, which is not defined in Scala2.x.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 4 |
1 files changed, 2 insertions, 2 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 |