E231: Concrete Class Has Unimplemented Methods
This error is emitted when a non-abstract class or object extends a trait or abstract class but does not provide implementations for one or more of its inherited abstract members.
A class must either implement every inherited abstract member in itself or one of its ancestors, or be declared abstract so that subclasses are required to finish the job.
Example
trait Animal:
def name: String
def sound: String
class Dog extends Animal
Error
-- [E231] Declaration Error: example.scala:5:6 ---------------------------------
5 |class Dog extends Animal
| ^^^
| class Dog needs to be abstract, since it has 2 unimplemented members.
|
| Members declared in Animal:
| - def name: String
| - def sound: String
Solution
Either implement all missing members:
trait Animal:
def name: String
def sound: String
class Dog extends Animal:
def name: String = "Rex"
def sound: String = "Woof"
Or mark the class as abstract to defer the obligation to subclasses:
trait Animal:
def name: String
def sound: String
abstract class Dog extends Animal
In this article