Closed
Description
Minimized code
inline def f(inline x: Int): Unit = {
inline val twice = x + x
}
def test: Unit = f(3)
Output
-- Error: Foo.scala:7:18 -------------------------------------------------------
7 |def test: Unit = f(3)
| ^^^^
| type of inline must be a known value
| This location contains code that was inlined from Foo.scala:3
result of Foo.scala after typer:
package <empty> {
final lazy module val Foo$package: Foo$package$ = new Foo$package$()
final module class Foo$package$() extends Object(), _root_.scala.Serializable
{
this: Foo$package.type =>
inline def f(inline x: Int): Unit =
{
inline val twice: Int = x.+(x)
()
}:Unit
def test: Unit =
{
{
inline val twice: Int = 6
()
}:Unit
}
}
}
Expectation
When f
is inlined, the type of twice
should be 6
. Therewise we wont be able to inline this value.
def test: Unit =
{
{
inline val twice: 6 = 6
()
}:Unit
}