diff options
author | Martin Odersky <odersky@gmail.com> | 2014-12-20 21:51:06 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-12-20 21:51:06 +0100 |
commit | 7d513b4f3342c17e8b603a43c40770d0f97424de (patch) | |
tree | 977497ac89abe9a1a4122b148100016d9d6f98a1 /src/dotty/tools/dotc/ast/Desugar.scala | |
parent | eb4bb1d092014be19b1669a7c16c6df3e11fda28 (diff) | |
download | dotty-7d513b4f3342c17e8b603a43c40770d0f97424de.tar.gz dotty-7d513b4f3342c17e8b603a43c40770d0f97424de.tar.bz2 dotty-7d513b4f3342c17e8b603a43c40770d0f97424de.zip |
Don't emit copy method for case classes with repeated parameters.
scalac has the same restriction. The reason is that we do not have a means
to specify a sequence-valued default for a vararg parameter.
It would be nice if we could, but this requires a more substantial development
effort.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 05f652a39..32ada504d 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -290,8 +290,12 @@ object desugar { val caseParams = constrVparamss.head.toArray val productElemMeths = for (i <- 0 until arity) yield syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeName), caseParams(i).name)) + val hasRepeatedParam = constrVparamss.exists(_.exists { + case ValDef(_, PostfixOp(_, nme.raw.STAR), _) => true + case _ => false + }) val copyMeths = - if (mods is Abstract) Nil + if (mods.is(Abstract) || hasRepeatedParam) Nil // cannot have default arguments for repeated parameters, hence copy method is not issued else { def copyDefault(vparam: ValDef) = makeAnnotated(defn.UncheckedVarianceAnnot, refOfDef(vparam)) |