What happens if I claim 'override' but no parent method matches?

← Override Mechanics · Ref: Q572

Note: override applies to both methods and operators (e.g., override operator ? as pure, override operator $ as pure).

If you mark a method with 'override' but no parent class or trait has a matching method, the compiler reports E05100. This catches typos and stale overrides.

THE ERROR: E05100

E05100 fires when 'override' is used but no matching method exists in any parent. Common causes: method name typo, parent method was renamed or removed, wrong parent class.

FIX: REMOVE OVERRIDE

If this is a new method, remove the 'override' keyword:

  //Before (error):
  override newMethod()
    <- rtn as String: "new"
  //After (correct):
  newMethod()
    <- rtn as String: "new"

FIX: CORRECT THE NAME

If you intended to override, fix the method name to match the parent:

  //Before (error, typo):
  override procss()
  //After (correct):
  override process()

FIX: CHECK SIGNATURES

The override must match the parent signature exactly. Different parameter types mean no match.

SAFETY NET

E05100 is a safety net against stale code. When a parent method is renamed, all child overrides immediately break with E05100, forcing you to update them.

See Q570 for override basics. See Q571 for the opposite: missing override keyword. See Q573 for access modifier rules.

Example

defines module qa.override.falseclaim

  defines class

    Renderer as open
      render() as pure
        -> content as String
        <- rtn as String: content

      default operator ?

    //Correct: override matches parent method exactly
    HtmlRenderer extends Renderer
      override render() as pure
        -> content as String
        <- rtn as String: `<p>${content}</p>`

      //New method: no override keyword (no parent match)
      renderWithTag() as pure
        ->
          content as String
          tag as String
        <- rtn as String: `<${tag}>${content}</${tag}>`

      default operator ?

  defines program

    FalseOverrideClaimDemo()
      stdout <- Stdout()

      renderer <- HtmlRenderer()
      stdout.println(renderer.render("hello"))
      stdout.println(renderer.renderWithTag("hello", "div"))

Common mistakes

E05110 — Adding override to renderWithTag would be a false claim since Renderer has no method named renderWithTag. The compiler rejects override when no parent method matches. See ek9 -h E05110 for details.

Incorrect:

override renderWithTag() as pure

Correct:

renderWithTag() as pure

E05120 — Omitting override on the render method in HtmlRenderer would be detected as method shadowing since the parent Renderer already defines render. See ek9 -h E05120 for details.

Incorrect:

render() as pure

Correct:

override render() as pure
Other ways to ask this
  • What is E05100 override inappropriate?
  • Why does the compiler say my override has nothing to override?
  • How do I fix a false override claim?

Coming from another language?

Java: @Override produces compile error if nothing to override. Kotlin: override keyword causes error if nothing matches. C#: override without matching virtual method is an error. EK9: E05100 when override has no matching parent method.

Keywords: false, mismatch, E05100, parent, override, inherit, function, claim, abstract, typo, virtual, inappropriate, open