Open
Description
Whenever we perform an inline match we need o bind the matched expression before using it in the RHS of the pattern. This is the correct behavior.
class Foo:
inline def f(inline x: Option[Int]) =
inline x match
case Some(y) => y + y
case _ => ???
def test: Unit =
val a: Int = 5
f(Some(a))
// val y = a
// a + a
Unfortunately, this blocks further optimizations or inline matches. We could introduce an inline bindings to allow those extracted terms to be used as they are. Just like in inline parameters. It would look like
inline x match
case Some(inline y) => y + y
then the result of f(Some(a))
would just be a + a
.