E07020: 'override' of a method/operator and 'abstract' (no implementation) is not logical
What went wrong
You've marked a method as BOTH 'override' AND 'abstract'. These are mutually exclusive - 'override' means IMPLEMENTING, 'abstract' means NOT implementing.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 768 (Why can't an abstract method have a body in EK9?)
How to fix it
- Choose ONE: either abstract OR override
- Abstract = defer implementation to subclass
- Override = provide implementation now
Common causes
- Confusion about method intent
- Copy/paste error from different context
- Incomplete refactoring
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07020: 'override' of a method/operator and 'abstract' (no implementation) is not logical
#!ek9 defines module error.e07020.bad defines class Shape as abstract area() as abstract <- rtn as Float? Polygon extends Shape as abstract //override says "this implements it", abstract says "there is no implementation" override area() as abstract <- rtn as Float?
Fixed: Either implement it with override, or leave it abstract and do not redeclare it
#!ek9 defines module error.e07020.good defines class Shape as abstract area() as abstract <- rtn as Float? //Still abstract: it simply inherits area() and does not redeclare it Polygon extends Shape as abstract sides() as abstract <- rtn as Integer? //Concrete: it overrides area() with a body Square extends Polygon override area() <- rtn as Float: 4.0 override sides() <- rtn as Integer: 4
Questions and answers
These Q&A entries show E07020 and its fix:
Found a problem?
If EK9 reported E07020 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.