diff options
author | Martin Odersky <odersky@gmail.com> | 2015-10-21 16:58:28 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-22 12:21:25 +0200 |
commit | 4e49976c8f4a19fd8533a0bb8543c4a2f2076f64 (patch) | |
tree | 6cf4db46ff7c3352646a2bf9cc645b37d88cd14a /src/dotty/tools/dotc/ast/Desugar.scala | |
parent | 3da5e04e286ee74781fda9e3b8776e5a8644712a (diff) | |
download | dotty-4e49976c8f4a19fd8533a0bb8543c4a2f2076f64.tar.gz dotty-4e49976c8f4a19fd8533a0bb8543c4a2f2076f64.tar.bz2 dotty-4e49976c8f4a19fd8533a0bb8543c4a2f2076f64.zip |
Avoif follow-on errors for illegal implicit classes
Supporess creation of implicit factory if it would be illegal.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index b834211ac..d1f101283 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -380,18 +380,22 @@ object desugar { // synthetic implicit C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, ..., pMN: TMN): C[Ts] = // new C[Ts](p11, ..., p1N) ... (pM1, ..., pMN) = val implicitWrappers = - if (mods is Implicit) { - if (ctx.owner is Package) - ctx.error("implicit classes may not be toplevel", cdef.pos) - if (mods is Case) - ctx.error("implicit classes may not case classes", cdef.pos) - + if (!mods.is(Implicit)) + Nil + else if (ctx.owner is Package) { + ctx.error("implicit classes may not be toplevel", cdef.pos) + Nil + } + else if (mods is Case) { + ctx.error("implicit classes may not be case classes", cdef.pos) + Nil + } + else // implicit wrapper is typechecked in same scope as constructor, so // we can reuse the constructor parameters; no derived params are needed. DefDef(name.toTermName, constrTparams, constrVparamss, classTypeRef, creatorExpr) .withFlags(Synthetic | Implicit) :: Nil - } - else Nil + val self1 = { val selfType = if (self.tpt.isEmpty) classTypeRef else self.tpt |