Skip to content

Commit 5920b74

Browse files
Merge pull request #1815 from dotty-staging/fix-#1797
Fix #1797: Allow case class params with names _1, _2, ...
2 parents 9bbd043 + 403a16f commit 5920b74

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,9 @@ object desugar {
343343
def syntheticProperty(name: TermName, rhs: Tree) =
344344
DefDef(name, Nil, Nil, TypeTree(), rhs).withMods(synthetic)
345345
val caseParams = constrVparamss.head.toArray
346-
val productElemMeths = for (i <- 0 until arity) yield
347-
syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeIdent), caseParams(i).name))
346+
val productElemMeths =
347+
for (i <- 0 until arity if nme.selectorName(i) `ne` caseParams(i).name)
348+
yield syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeIdent), caseParams(i).name))
348349
def isRepeated(tree: Tree): Boolean = tree match {
349350
case PostfixOp(_, nme.raw.STAR) => true
350351
case ByNameTypeTree(tree1) => isRepeated(tree1)

tests/pos/i1797.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
case class Tuple1[T](_1: T)

0 commit comments

Comments
 (0)