E050: Method Does Not Take Parameters
This error is emitted when you try to pass arguments to a method or expression that doesn't accept parameters.
This can happen when:
- Calling a nullary method (no parameter list) with arguments
- Calling a method with more argument lists than it accepts
- Applying arguments to an expression that is not a function
Example
object Hello
val message = Hello("World")
Error
-- [E050] Type Error: example.scala:2:14 ---------------------------------------
2 |val message = Hello("World")
| ^^^^^
| object Hello does not take parameters
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| You have specified more parameter lists than defined in the method definition(s).
-----------------------------------------------------------------------------
Solution
// Enusre that method you want to call exists, especially if it involved Scala syntax desugaring
object Hello:
def apply(value: String) = ???
val message = Hello("World")
// Enusre that that method actually takes arguments list
class Bag extends scala.reflect.Selectable
def example =
val bag = new Bag:
val f1 = 23
val x = bag.f1 // instead of bag.f1()
In this article