diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-02 16:42:00 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-02 16:42:00 +0100 |
commit | af39d28ed9a30274efaadd26573f43891550dc6d (patch) | |
tree | f0c584df53bf9106047a693bfbdca7b923652924 /compiler | |
parent | 16671a00371df2bdbaf6ae7f51b0ec7191ce94f3 (diff) | |
download | dotty-af39d28ed9a30274efaadd26573f43891550dc6d.tar.gz dotty-af39d28ed9a30274efaadd26573f43891550dc6d.tar.bz2 dotty-af39d28ed9a30274efaadd26573f43891550dc6d.zip |
Handle hk types with context bounds in desugar
With the change to the representation of higher-kinded type definitions,
context bounds could be hidden in the body of a type lambda. Need to
compensate for that.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/Desugar.scala | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index c8b1ed909..61977be04 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -142,16 +142,21 @@ object desugar { val DefDef(name, tparams, vparamss, tpt, rhs) = meth val mods = meth.mods val epbuf = new ListBuffer[ValDef] - val tparams1 = tparams mapConserve { - case tparam @ TypeDef(_, ContextBounds(tbounds, cxbounds)) => + def desugarContextBounds(rhs: Tree): Tree = rhs match { + case ContextBounds(tbounds, cxbounds) => for (cxbound <- cxbounds) { val paramFlags: FlagSet = if (isPrimaryConstructor) PrivateLocalParamAccessor else Param val epname = ctx.freshName(nme.EVIDENCE_PARAM_PREFIX).toTermName epbuf += ValDef(epname, cxbound, EmptyTree).withFlags(paramFlags | Implicit) } - cpy.TypeDef(tparam)(rhs = tbounds) - case tparam => - tparam + tbounds + case PolyTypeTree(tparams, body) => + cpy.PolyTypeTree(rhs)(tparams, desugarContextBounds(body)) + case _ => + rhs + } + val tparams1 = tparams mapConserve { tdef => + cpy.TypeDef(tdef)(rhs = desugarContextBounds(tdef.rhs)) } val meth1 = addEvidenceParams(cpy.DefDef(meth)(tparams = tparams1), epbuf.toList) |