E063: Only Classes Can Be Abstract

This error is emitted when the abstract modifier is used on something other than a class, such as a method or value.

The abstract modifier can only be used for classes. For abstract members (methods, values), simply omit the implementation - they are implicitly abstract when declared without a body in a trait or abstract class.


Example

trait Example:
  abstract def method: Int

Error

-- [E063] Syntax Error: example.scala:2:15 -------------------------------------
2 |  abstract def method: Int
  |               ^
  |abstract modifier can be used only for classes; it should be omitted for abstract members

Solution

// Simply omit abstract for member declarations
trait Example:
  def method: Int
// Use abstract only for class definitions
abstract class Example:
  def method: Int
  def concreteMethod: Int = 42