E060: Abstract Member May Not Have Modifier

This error is emitted when an abstract member is declared with a modifier that is incompatible with being abstract, such as final or private.

Abstract members are meant to be implemented by subclasses, so they cannot be final (which prevents overriding) or private (which prevents access by subclasses).


Example

trait Example:
  final def abstractMethod: Int

Error

-- [E060] Syntax Error: example.scala:2:12 -------------------------------------
2 |  final def abstractMethod: Int
  |            ^
  |            abstract method abstractMethod may not have `final` modifier

Solution

// Remove the incompatible modifier
trait Example:
  def abstractMethod: Int
// Or provide an implementation if you want final
trait Example:
  final def concreteMethod: Int = 42