Skip to content

Commit 9987b88

Browse files
oderskymichelou
authored andcommitted
Allow for ranges in parameters of mapped lambda types
Fixes scala#12384
1 parent e84cd47 commit 9987b88

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5650,7 +5650,12 @@ object Types {
56505650
case Range(lo, hi) =>
56515651
range(derivedLambdaType(tp)(formals, lo), derivedLambdaType(tp)(formals, hi))
56525652
case _ =>
5653-
tp.derivedLambdaType(tp.paramNames, formals, restpe)
5653+
if formals.exists(isRange) then
5654+
range(
5655+
derivedLambdaType(tp)(formals.map(upper(_).asInstanceOf[tp.PInfo]), restpe),
5656+
derivedLambdaType(tp)(formals.map(lower(_).asInstanceOf[tp.PInfo]), restpe))
5657+
else
5658+
tp.derivedLambdaType(tp.paramNames, formals, restpe)
56545659
}
56555660

56565661
protected def reapply(tp: Type): Type = apply(tp)

tests/neg/i12384.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Nats {
2+
trait Fold {
3+
trait Nat
4+
}
5+
type Inc = Fold {
6+
type Apply[N <: Nat] = Succ // error
7+
}
8+
}

0 commit comments

Comments
 (0)