E11044: override method body is identical to super - remove the override

Category: E11xxx Code quality and IR analysis · Reported in phase: PRE_IR_CHECKS · Classification: REDUNDANT_OVERRIDE · All error codes

What went wrong

Your override method body is textually identical to the method it overrides in the super class or trait. The override adds no value - it duplicates existing behaviour that would be inherited automatically.

When this error triggers

  1. A method is marked 'override'
  2. The super class/trait has a concrete implementation of that method
  3. The override body is textually identical to the super body

This indicates either:

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

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 801 (Why does EK9 reject overrides identical to the parent met...)

How to fix it

  1. REMOVE THE REDUNDANT OVERRIDE
  • Delete the override method entirely
  • The inherited implementation provides identical behaviour
  1. IF YOU INTENDED DIFFERENT BEHAVIOUR
  • Modify the override body to actually differ from the super
  • Even small differences (logging, validation) justify the override

Transform

The [EXAMPLE] section below shows a Derived class overriding 'doWork()' with exactly the body it inherits, then a Derived that simply inherits it (and a Shouty whose override genuinely differs).

Exception - trait method conflicts

When a class implements two or more traits that define the same method signature, EK9 REQUIRES the developer to provide an override (E06150). In this situation the override is NOT flagged as redundant - even if the body matches one of the trait implementations. The override is compelled by the language (good_conflict.ek9 below: a Service with trait of Logger and Auditor, both of which supply 'log()').

Why this matters

  • Dead code obscures intent and confuses maintainers
  • Redundant overrides mask genuinely important overrides in the same class
  • Increases maintenance cost when the super method changes (two copies to update)
  • AI-generated code frequently produces unnecessary overrides

Research basis

  • Fowler, M.: 'Refactoring' (1999) - Remove Middle Man, Inline Method
  • Martin, R.: 'Clean Code' (2008) - DRY principle, minimal code

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E11044: override method body is identical to super - remove the override

#!ek9
defines module error.e11044.bad

  defines class

    Base as open
      doWork()
        <- rtn as String: "working"

    Derived extends Base
      override doWork()
        <- rtn as String: "working"

Fixed: Remove an override that repeats the super - or make it do something different

#!ek9
defines module error.e11044.good

  defines class

    Base as open
      doWork()
        <- rtn as String: "working"

    Derived extends Base

    Shouty extends Base
      override doWork()
        <- rtn as String: "WORKING"

Fixed: An override two traits compel is never redundant

#!ek9
defines module error.e11044.good.conflict

  defines trait
    Logger
      log()
        -> message as String
        stdout <- Stdout()
        stdout.println(message)

    Auditor
      log()
        -> message as String
        stdout <- Stdout()
        stdout.println(message)

  defines class
    //Both traits supply log(): the override is REQUIRED (E06150), so it is not flagged
    Service with trait of Logger, Auditor
      override log()
        -> message as String
        stdout <- Stdout()
        stdout.println(message)

Questions and answers

These Q&A entries show E11044 and its fix: