What happens if I forget the 'override' keyword?
← Override Mechanics · Ref: Q571
If your method has the same name and signature as a parent method but you omit the 'override' keyword, the compiler reports E05110. This prevents accidental method shadowing.
THE ERROR: E05110
E05110 fires when a method matches a parent method exactly but lacks the 'override' keyword. The compiler refuses to silently shadow the parent behavior.
FIX: ADD OVERRIDE
Simply add 'override' before the method name:
//Before (error): process() <- rtn as String: "child" //After (correct): override process() <- rtn as String: "child"
ALTERNATIVE: RENAME
If you intended a new method (not an override), rename it to avoid matching the parent signature.
WHY EXPLICIT OVERRIDE MATTERS
In large codebases, methods can accidentally match parent signatures after refactoring. Without mandatory override, this creates subtle bugs where the child silently replaces parent behavior. EK9 catches this at compile time.
See Q570 for override basics. See Q572 for the opposite: claiming override when nothing matches. See Q105 for method dispatch.
Example
defines module qa.override.missingkeyword defines class Greeter as open greet() as pure -> recipient as String <- rtn as String: "Hello, " + recipient farewell() as pure -> recipient as String <- rtn as String: "Goodbye, " + recipient default operator ? //Correct: override keyword is present FormalGreeter extends Greeter override greet() as pure -> recipient as String <- rtn as String: "Good day, " + recipient override farewell() as pure -> recipient as String <- rtn as String: "Farewell, " + recipient //New method: no override needed (different name) bow() as pure -> recipient as String <- rtn as String: "Bowing to " + recipient default operator ? defines program MissingOverrideDemo() stdout <- Stdout() recipientName <- "Alice" greeter <- FormalGreeter() stdout.println(greeter.greet(recipientName)) stdout.println(greeter.farewell(recipientName)) stdout.println(greeter.bow(recipientName))
Common mistakes
E05120 — When a method matches a parent method signature, omitting override causes a shadowing error. The compiler requires explicit intent. See ek9 -h E05120 for details.
Incorrect:
greet() as pure
Correct:
override greet() as pure
E05120 — Claiming override on bow() would be a false claim since no parent method named bow exists. The override keyword must match an actual parent method. See ek9 -h E02030 for details.
Incorrect:
farewell() as pure
Correct:
override farewell() as pure
Other ways to ask this
- What is E05110 does not override?
- Why does the compiler reject my method that matches the parent?
- How do I fix E05110 missing override?
Coming from another language?
Java: @Override is optional, shadowing is silent without it. Python: no override mechanism. Kotlin: override is mandatory (same as EK9). C#: override keyword required for virtual methods. EK9: override is mandatory, E05110 reported if missing.
Keywords: parent, keyword, explicit, virtual, open, shadow, E05110, missing, match, override, inherit, abstract