E07010: remove 'override' with use of 'private' access modifier
What went wrong
You've marked a PRIVATE method with 'override', but private methods cannot override anything - they are invisible to subclasses.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 573 (What are the access modifier rules for method overrides?)
- ek9 -q 676 (How do override and access modifiers interact in a three-...)
How to fix it
- Remove 'override' if this is a new private method
- Change to protected/public if it should truly override
- Private methods are always independent in each class
Common causes
- Method was public, got changed to private, 'override' left behind
- Copy/paste from non-private method
- Misunderstanding private visibility
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07010: remove 'override' with use of 'private' access modifier
#!ek9 defines module error.e07010.bad defines class Account as open private auditCode() <- rtn as String: "A" Savings extends Account //A private method cannot override, and a private parent method cannot be overridden override private auditCode() <- rtn as String: "S"
Fixed: Override a visible method, and drop private
#!ek9 defines module error.e07010.good defines class Account as open auditCode() <- rtn as String: "A" Savings extends Account override auditCode() <- rtn as String: "S"
Questions and answers
These Q&A entries show E07010 and its fix: