Back to Scala3

E054: Parameterized Type Lacks Arguments

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

3.8.41.6 KB
Original Source

E054: Parameterized Type Lacks Arguments

Note This error was replaced in Scala 3.2.2 by a more specific error message E171: Missing Argument.

Error was triggered when extending a parameterized type without providing the required constructor arguments.

Example

scala
trait Foo(x: Int)

val foo = new Foo {}

Error

scala
-- [E054] Type Error: example.scala:3:14 ---------------------------------------
3 |val foo = new Foo {}
  |              ^^^
  |              Parameterized trait Foo lacks argument list
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | The trait Foo is declared with non-implicit parameters, you may not leave
  | out the parameter list when extending it.
   -----------------------------------------------------------------------------

Explanation

When a class or trait declares constructor parameters, you must provide values for those parameters when extending it. The error occurred because Foo requires an Int argument but none was provided.

The fix was to provide the required arguments:

scala
trait Foo(x: Int)

val foo = new Foo(42) {}
<!-- 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>