E053: Type Does Not Take Parameters
This error is emitted when type parameters are provided to a type that doesn't accept any type parameters.
You specified type parameters for a type that is not declared to take any. This can happen when:
- Applying type arguments to a non-generic type
- Confusing a type alias with its underlying parameterized type
- Using F-bounds where type lambdas are not allowed
Example
val x: Int[String] = 42
Error
-- [E053] Type Error: example.scala:1:7 ----------------------------------------
1 |val x: Int[String] = 42
| ^^^^^^^^^^^
| Int does not take type parameters
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| You specified a type parameter Ident(String) for Int, which is not
| declared to take any.
-----------------------------------------------------------------------------
Solution
// Remove the type parameters from non-generic types
val x: Int = 42
// Use a type that does accept parameters
val x: List[Int] = List(42)
// Or define your own generic type
class Box[T](value: T)
val x: Box[Int] = Box(42)
In this article