diff options
author | Martin Odersky <odersky@gmail.com> | 2017-02-14 09:45:44 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-04 13:29:38 +0200 |
commit | 4bdad3c21a1461bed6e91ef69dd767fa5211f60d (patch) | |
tree | 79cc5cd66c51519e399f2617d1f5f553fd321e25 /compiler/src/dotty/tools | |
parent | c58555e434d886e079104b0311ecb523f4ee1b40 (diff) | |
download | dotty-4bdad3c21a1461bed6e91ef69dd767fa5211f60d.tar.gz dotty-4bdad3c21a1461bed6e91ef69dd767fa5211f60d.tar.bz2 dotty-4bdad3c21a1461bed6e91ef69dd767fa5211f60d.zip |
Change return type of `apply`.
In an enum case like
case C() extends P1 with ... with Pn ...
apply now returns `P1 & ... & Pn`, where before
it was just P1.
Also, add to Option test.
Diffstat (limited to 'compiler/src/dotty/tools')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/Desugar.scala | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index aa073429d..575af97f4 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -344,13 +344,6 @@ object desugar { // new C[Ts](paramss) lazy val creatorExpr = New(classTypeRef, constrVparamss nestedMap refOfDef) - // The return type of the `apply` and `copy` methods - val applyResultTpt = - if (isEnumCase) - if (parents.isEmpty) enumClassTypeRef - else parents.head - else TypeTree() - // Methods to add to a case class C[..](p1: T1, ..., pN: Tn)(moreParams) // def isDefined = true // def productArity = N @@ -436,6 +429,13 @@ object desugar { // For all other classes, the parent is AnyRef. val companions = if (isCaseClass) { + // The return type of the `apply` method + val applyResultTpt = + if (isEnumCase) + if (parents.isEmpty) enumClassTypeRef + else parents.reduceLeft(AndTypeTree) + else TypeTree() + val parent = if (constrTparams.nonEmpty || constrVparamss.length > 1 || |