From 3cff997140d163b428f0fb88ea36bf9537c78a6c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 14 Feb 2022 09:14:31 +0100 Subject: [PATCH] Document that inline methods are not eta expanded Fixes #14449 --- docs/_docs/reference/metaprogramming/inline.md | 11 +++++++++++ tests/pos/reference/inlines.scala | 2 ++ 2 files changed, 13 insertions(+) diff --git a/docs/_docs/reference/metaprogramming/inline.md b/docs/_docs/reference/metaprogramming/inline.md index 8ccef49872b7..c625f4774a18 100644 --- a/docs/_docs/reference/metaprogramming/inline.md +++ b/docs/_docs/reference/metaprogramming/inline.md @@ -90,6 +90,17 @@ semantics, by binding the value and reusing the `msg` through the body of `factorial`. Also, note the special handling of the assignment to the private var `indent`. It is achieved by generating a setter method `def inline$indent_=` and calling it instead. +Inline methods always have to be fully applied. For instance, a call to +```scala +Logger.log[String]("some op", indentSetting) +``` +would be ill-formed and the compiler would complain that arguments are missing. +However, it is possible to pass wildcard arguments instead. For instance, +```scala +Logger.log[String]("some op", indentSetting)(_) +``` +would typecheck. + ### Recursive Inline Methods Inline methods can be recursive. For instance, when called with a constant diff --git a/tests/pos/reference/inlines.scala b/tests/pos/reference/inlines.scala index a1eb215b4d22..657961671efd 100644 --- a/tests/pos/reference/inlines.scala +++ b/tests/pos/reference/inlines.scala @@ -41,6 +41,8 @@ object Test{ } } + val x = log[String]("some op", indentSetting)(_) + def main(args: Array[String]): Unit = println(factorial(33)) }