Skip to content

Commit 7d513b4

Browse files
committed
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.
1 parent eb4bb1d commit 7d513b4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,12 @@ object desugar {
290290
val caseParams = constrVparamss.head.toArray
291291
val productElemMeths = for (i <- 0 until arity) yield
292292
syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeName), caseParams(i).name))
293+
val hasRepeatedParam = constrVparamss.exists(_.exists {
294+
case ValDef(_, PostfixOp(_, nme.raw.STAR), _) => true
295+
case _ => false
296+
})
293297
val copyMeths =
294-
if (mods is Abstract) Nil
298+
if (mods.is(Abstract) || hasRepeatedParam) Nil // cannot have default arguments for repeated parameters, hence copy method is not issued
295299
else {
296300
def copyDefault(vparam: ValDef) =
297301
makeAnnotated(defn.UncheckedVarianceAnnot, refOfDef(vparam))

0 commit comments

Comments
 (0)