Skip to content

Commit af39d28

Browse files
committed
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.
1 parent 16671a0 commit af39d28

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,21 @@ object desugar {
142142
val DefDef(name, tparams, vparamss, tpt, rhs) = meth
143143
val mods = meth.mods
144144
val epbuf = new ListBuffer[ValDef]
145-
val tparams1 = tparams mapConserve {
146-
case tparam @ TypeDef(_, ContextBounds(tbounds, cxbounds)) =>
145+
def desugarContextBounds(rhs: Tree): Tree = rhs match {
146+
case ContextBounds(tbounds, cxbounds) =>
147147
for (cxbound <- cxbounds) {
148148
val paramFlags: FlagSet = if (isPrimaryConstructor) PrivateLocalParamAccessor else Param
149149
val epname = ctx.freshName(nme.EVIDENCE_PARAM_PREFIX).toTermName
150150
epbuf += ValDef(epname, cxbound, EmptyTree).withFlags(paramFlags | Implicit)
151151
}
152-
cpy.TypeDef(tparam)(rhs = tbounds)
153-
case tparam =>
154-
tparam
152+
tbounds
153+
case PolyTypeTree(tparams, body) =>
154+
cpy.PolyTypeTree(rhs)(tparams, desugarContextBounds(body))
155+
case _ =>
156+
rhs
157+
}
158+
val tparams1 = tparams mapConserve { tdef =>
159+
cpy.TypeDef(tdef)(rhs = desugarContextBounds(tdef.rhs))
155160
}
156161

157162
val meth1 = addEvidenceParams(cpy.DefDef(meth)(tparams = tparams1), epbuf.toList)

0 commit comments

Comments
 (0)