Skip to content

Commit d6be581

Browse files
authored
Merge pull request #7902 from dotty-staging/fix-#7878
Fix #7878: Make sure implicit match case bindings are properly substi…
2 parents 947316d + 19a968b commit d6be581

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
10351035
case _ => false
10361036
}
10371037
}
1038-
if (guardOK) Some((caseBindings, cdef.body.subst(from, to)))
1038+
if (guardOK) Some((caseBindings.map(_.subst(from, to)), cdef.body.subst(from, to)))
10391039
else None
10401040
}
10411041
else None
@@ -1135,7 +1135,6 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
11351135
}
11361136
case _ => rhs0
11371137
}
1138-
11391138
val (usedBindings, rhs2) = dropUnusedDefs(caseBindings, rhs1)
11401139
val rhs = seq(usedBindings, rhs2)
11411140
inlining.println(i"""--- reduce:

tests/pos/i7878.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Boom {
2+
import scala.compiletime._
3+
trait Fail[A <: Int, B <: Int]
4+
5+
erased inline given fail[X <: Int, Y <: Int]: Fail[X, Y] = {
6+
scala.compiletime.summonFrom {
7+
case t: Fail[X, y] if constValue[y] < constValue[Y] => ???
8+
}
9+
}
10+
11+
val a: Int = 1
12+
given ev1: Fail[a.type, 2] = null
13+
14+
summon[Fail[a.type, 3]]
15+
}

0 commit comments

Comments
 (0)