Skip to content

Commit c3d4999

Browse files
Merge pull request #14474 from dotty-staging/fix-14449
Document that inline methods are not eta expanded
2 parents 7285ea9 + 3cff997 commit c3d4999

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/_docs/reference/metaprogramming/inline.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ semantics, by binding the value and reusing the `msg` through the body of
9090
`factorial`. Also, note the special handling of the assignment to the private var
9191
`indent`. It is achieved by generating a setter method `def inline$indent_=` and calling it instead.
9292

93+
Inline methods always have to be fully applied. For instance, a call to
94+
```scala
95+
Logger.log[String]("some op", indentSetting)
96+
```
97+
would be ill-formed and the compiler would complain that arguments are missing.
98+
However, it is possible to pass wildcard arguments instead. For instance,
99+
```scala
100+
Logger.log[String]("some op", indentSetting)(_)
101+
```
102+
would typecheck.
103+
93104
### Recursive Inline Methods
94105

95106
Inline methods can be recursive. For instance, when called with a constant

tests/pos/reference/inlines.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ object Test{
4141
}
4242
}
4343

44+
val x = log[String]("some op", indentSetting)(_)
45+
4446
def main(args: Array[String]): Unit =
4547
println(factorial(33))
4648
}

0 commit comments

Comments
 (0)