E224: Override Class

This deprecation warning is emitted when the override modifier is used on a class or trait definition.

Using override directly on a class or trait to override a type member is deprecated. Instead, you should define the class separately and override the type member with a type alias pointing to the new class.


Example

trait Base:
  type T

object Impl extends Base:
  override class T

Warning

-- [E224] Syntax Deprecation Warning: example.scala:5:17 -----------------------
5 |  override class T
  |                 ^
  |                 `override` modifier is deprecated for classes and traits
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Instead of overriding a type alias with a class type, use an alias of the class.
  | For example, instead of `override class C`, use `override type C = CImpl; class CImpl`.
   -----------------------------------------------------------------------------

Solution

Define the class separately and use a type alias override:

trait Base:
  type T

object Impl extends Base:
  class TImpl
  override type T = TImpl