Skip to content

Cannot inherit final override toString in companion object of case class #16879

Closed
@CoolDalek

Description

@CoolDalek

Compiler version

3.2.1 and 3.2.2

Minimized code

trait Companion:
  final override def toString: String = "Companion"

case class Example(value: Int)
object Example extends Companion

Output

error overriding method toString in trait Companion of type => String;
  method toString of type => String cannot override final member method toString in trait Companion
case class Example(value: Int)

Expectation

Companion object inherits toString implementation from the trait.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions