Skip to content

Commit e18713f

Browse files
committed
Allow for ranges in parameters of mapped lambda types
Fixes #12384
1 parent 69c800b commit e18713f

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
@@ -5640,7 +5640,12 @@ object Types {
56405640
case Range(lo, hi) =>
56415641
range(derivedLambdaType(tp)(formals, lo), derivedLambdaType(tp)(formals, hi))
56425642
case _ =>
5643-
tp.derivedLambdaType(tp.paramNames, formals, restpe)
5643+
if formals.exists(isRange) then
5644+
range(
5645+
derivedLambdaType(tp)(formals.map(upper(_).asInstanceOf[tp.PInfo]), restpe),
5646+
derivedLambdaType(tp)(formals.map(lower(_).asInstanceOf[tp.PInfo]), restpe))
5647+
else
5648+
tp.derivedLambdaType(tp.paramNames, formals, restpe)
56445649
}
56455650

56465651
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)