Why does EK9 reject overrides identical to the parent method?

← Code Quality · Ref: Q801

EK9 raises E11044 when an override method body is textually identical to the method it overrides in the parent class. The override adds no value and duplicates inherited behaviour.

WHY REJECTED

- Copy-paste from the parent class without modification
- Incomplete refactoring where the override was meant to change behaviour
- Misunderstanding of inheritance (overrides are only needed to CHANGE behaviour)

FIX OPTIONS

1. Remove the override entirely - inherited implementation provides identical behaviour
2. Actually modify the method body to add new behaviour
3. Call super and add additional logic

See Q800 for repeated literals. See Q777 for discarded returns.

Example

defines module qa.codequality.redundantoverride

  defines class

    Formatter as open

      format()
        -> inputText as String
        <- formatted as String: String()

        formatted: `[${inputText}]`

      default operator ?

    EnhancedFormatter extends Formatter

      override format()
        -> inputText as String
        <- formatted as String: String()

        formatted: "Enhanced: " + inputText

      default operator ?

  defines program

    RedundantOverrideDemo()
      stdout <- Stdout()

      formatter <- EnhancedFormatter()
      styled <- formatter.format("hello")
      stdout.println(styled)

Common mistakes

E11044 — The override body is textually identical to the parent Formatter.format() method. Either remove the override to inherit the parent behaviour, or change the body to provide genuinely different behaviour. See ek9 -h E11044 for details.

Incorrect:

        formatted: `[${inputText}]`

Correct:

        formatted: "Enhanced: " + inputText
Other ways to ask this
  • What triggers E11044 redundant override?
  • Why can't I override a method with the same body?
  • What does redundant override mean in EK9?

Coming from another language?

Java: no compiler detection, IntelliJ warns. Python: no detection. Rust: no inheritance, uses trait composition. Kotlin: no detection, IntelliJ warns. Go: no inheritance. EK9: compile-time error E11044, redundant overrides cannot exist.

Keywords: paste, duplicate, copy, E11044, inherited, identical, parent, redundant, override