Skip to content

Commit 2d07ae8

Browse files
authored
Merge pull request #6400 from dotty-staging/fix-contextbounds
Fix #4996: Properly drop context bounds in type lambdas
2 parents 9d7d05d + 4d51cd7 commit 2d07ae8

File tree

29 files changed

+19
-6
lines changed

29 files changed

+19
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,19 @@ object desugar {
211211
case _ =>
212212
rhs
213213
}
214+
215+
def dropContextBounds(tparam: TypeDef): TypeDef = {
216+
def dropInRhs(rhs: Tree): Tree = rhs match {
217+
case ContextBounds(tbounds, _) =>
218+
tbounds
219+
case rhs @ LambdaTypeTree(tparams, body) =>
220+
cpy.LambdaTypeTree(rhs)(tparams, dropInRhs(body))
221+
case _ =>
222+
rhs
223+
}
224+
cpy.TypeDef(tparam)(rhs = dropInRhs(tparam.rhs))
225+
}
226+
214227
val tparams1 = tparams mapConserve { tparam =>
215228
cpy.TypeDef(tparam)(rhs = desugarContextBounds(tparam.rhs))
216229
}
@@ -239,17 +252,12 @@ object desugar {
239252
def normalizedVparamss = meth1.vparamss map (_ map (vparam =>
240253
cpy.ValDef(vparam)(rhs = EmptyTree)))
241254

242-
def dropContextBound(tparam: TypeDef) = tparam.rhs match {
243-
case ContextBounds(tbounds, _) => cpy.TypeDef(tparam)(rhs = tbounds)
244-
case _ => tparam
245-
}
246-
247255
def defaultGetters(vparamss: List[List[ValDef]], n: Int): List[DefDef] = vparamss match {
248256
case (vparam :: vparams) :: vparamss1 =>
249257
def defaultGetter: DefDef =
250258
DefDef(
251259
name = DefaultGetterName(methName, n),
252-
tparams = meth.tparams.map(tparam => dropContextBound(toDefParam(tparam))),
260+
tparams = meth.tparams.map(tparam => dropContextBounds(toDefParam(tparam))),
253261
vparamss = takeUpTo(normalizedVparamss.nestedMap(toDefParam), n),
254262
tpt = TypeTree(),
255263
rhs = vparam.rhs

tests/pending/fuzzy/0f12f42d878dcd4cb8b8ab62dbfb6b41861989b1.scala renamed to tests/fuzzy/0f12f42d878dcd4cb8b8ab62dbfb6b41861989b1.scala

File renamed without changes.

tests/pending/fuzzy/9baccf94095f1bd680e9bb75cc552d0784b8b9c2.scala renamed to tests/fuzzy/9baccf94095f1bd680e9bb75cc552d0784b8b9c2.scala

File renamed without changes.

tests/pending/fuzzy/AE-0226ee1e434532ec3de3137beba3853f20d0989c.scala renamed to tests/fuzzy/AE-0226ee1e434532ec3de3137beba3853f20d0989c.scala

File renamed without changes.

tests/pending/fuzzy/AE-1269a5ff86175ddf4edabf6ad706cb136a9003f1.scala renamed to tests/fuzzy/AE-1269a5ff86175ddf4edabf6ad706cb136a9003f1.scala

File renamed without changes.

tests/pending/fuzzy/AE-4f7e66f7ee706c59e8d8ba100db9d2bf0152b119.scala renamed to tests/fuzzy/AE-4f7e66f7ee706c59e8d8ba100db9d2bf0152b119.scala

File renamed without changes.

tests/pending/fuzzy/AE-589637d1f97047c051c4adc3142cfe97f620b471.scala renamed to tests/fuzzy/AE-589637d1f97047c051c4adc3142cfe97f620b471.scala

File renamed without changes.

tests/pending/fuzzy/AE-854cfacb52282336bde0799f1ddbb5bbef974b59.scala renamed to tests/fuzzy/AE-854cfacb52282336bde0799f1ddbb5bbef974b59.scala

File renamed without changes.

tests/pending/fuzzy/AE-9a131723f09b9f77c99c52b709965e580a61706e.scala renamed to tests/fuzzy/AE-9a131723f09b9f77c99c52b709965e580a61706e.scala

File renamed without changes.

tests/pending/fuzzy/AE-9fea5208d12255332071a58be4afc5275b9e8d64.scala renamed to tests/fuzzy/AE-9fea5208d12255332071a58be4afc5275b9e8d64.scala

File renamed without changes.

0 commit comments

Comments
 (0)