Skip to content

Document that inline methods are not eta expanded #14474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/_docs/reference/metaprogramming/inline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/reference/inlines.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ object Test{
}
}

val x = log[String]("some op", indentSetting)(_)

def main(args: Array[String]): Unit =
println(factorial(33))
}