Incompatibility of automatic eta expansion and inlining

Hi!

The following Scala 3 code (in Scastie) fails to compile:

inline def foo(i: Int) = i + 1
Some(10).map(foo)

The error message is “missing arguments for method foo”, which suggests that the compiler interprets the foo on the second line as an attempt to call foo without arguments, rather than eta-expanding it (like it would if foo wasn’t inlined).

Is this something that might get fixed in the future, or is there some fundamental technical reason that prevents inlining and automatic eta expansion from playing together nicely?

Thank you!

1 Like

It appears to be intentional. Or at least documented. Document that inline methods are not eta expanded by odersky · Pull Request #14474 · lampepfl/dotty · GitHub
But I have no idea why it shouldn’t work. It seems kind of arbitrary and annoying honestly.

1 Like