diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-15 18:00:27 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-15 18:00:27 +0100 |
commit | 403a16f70edfc95da4b575bbee05d3d7cbc90704 (patch) | |
tree | 2dd03fd70c6d8480de2f2b6608acfd267c30a254 /compiler/src/dotty/tools/dotc/ast/Desugar.scala | |
parent | a5620ab882b95ef60acf42814ac5568d5f93bdd4 (diff) | |
download | dotty-403a16f70edfc95da4b575bbee05d3d7cbc90704.tar.gz dotty-403a16f70edfc95da4b575bbee05d3d7cbc90704.tar.bz2 dotty-403a16f70edfc95da4b575bbee05d3d7cbc90704.zip |
Fix #1797: Allow case class params with names _1, _2, ...
This was not possible before because it clashed with the automatically
generated name of the accessor. We now allow it, by simply taking the
parameter(accessor) itself as the case class accessor if it already has
that name. But you still cannot write
case class C(_2: Int, _1: String)
nor should you be able to do this.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/Desugar.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 15cb0b665..50463efb8 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -345,8 +345,9 @@ object desugar { DefDef(name, Nil, Nil, TypeTree(), rhs).withMods(synthetic) val isDefinedMeth = syntheticProperty(nme.isDefined, Literal(Constant(true))) val caseParams = constrVparamss.head.toArray - val productElemMeths = for (i <- 0 until arity) yield - syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeIdent), caseParams(i).name)) + val productElemMeths = + for (i <- 0 until arity if nme.selectorName(i) `ne` caseParams(i).name) + yield syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeIdent), caseParams(i).name)) def isRepeated(tree: Tree): Boolean = tree match { case PostfixOp(_, nme.raw.STAR) => true case ByNameTypeTree(tree1) => isRepeated(tree1) |