Back to Scala3

E118: Params No Inline

docs/_docs/reference/error-codes/E118.md

3.8.41.1 KB
Original Source

E118: Params No Inline

This error is emitted when the inline modifier is used on parameters of a non-inline method.

The inline modifier on parameters is only allowed for parameters of inline methods, where it enables the parameter to be inlined at the call site.


Example

scala
def example(inline x: Int): Int = x + 1

Error

scala
-- [E118] Syntax Error: example.scala:1:19 -------------------------------------
1 |def example(inline x: Int): Int = x + 1
  |                   ^
  |         inline modifier can only be used for parameters of inline methods

Solution

scala
// Make the method inline as well
inline def example(inline x: Int): Int = x + 1
scala
// Or remove inline from the parameter
def example(x: Int): Int = x + 1
<!-- SOURCE-ONLY: Remove the notice below once this page has been manually updated. --> <aside class="warning"> This reference page was created with LLM assistance - the description of the error code may not be accurate or cover all possible scenarios. </aside>