E07050: 'abstract' modifier on a constructor is not logical
What went wrong
You've marked a constructor as 'abstract', but constructors MUST create instances - they can never be abstract.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 774 (Why can't a constructor be abstract in EK9?)
How to fix it
- Remove 'abstract' from constructor
- Use abstract factory method if you need polymorphic creation
- Constructors always create instances
Common causes
- Confusion between constructors and factory methods
- Trying to defer construction to subclasses
- Misunderstanding abstract semantics
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07050: 'abstract' modifier on a constructor is not logical
#!ek9 defines module error.e07050.bad defines class Counter as abstract //A constructor makes an object, so it cannot be abstract Counter() as abstract -> start as Integer
Fixed: Give the constructor a body
#!ek9 defines module error.e07050.good defines class Counter count as Integer? default private Counter() Counter() -> start as Integer this.count: start default operator ?
Questions and answers
These Q&A entries show E07050 and its fix: