E07120: base level implementation must be provided for dispatcher method
What went wrong
A method marked as 'dispatcher' (for multiple dispatch) is missing its implementation body. Dispatcher methods need a default implementation.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 771 (Why must a dispatcher method have a body in EK9?)
How to fix it
- Provide default implementation for dispatcher
- Dispatcher needs body for fallback when no specific match
- Add overloads for specific type dispatching
Common causes
- Forgot to add implementation to dispatcher
- Thinking dispatcher works like abstract
- Incomplete dispatcher definition
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07120: base level implementation must be provided for dispatcher method
#!ek9 defines module error.e07120.bad defines class Shape as open kind() <- rtn as String: "shape" Describer //The entry point is what runs when no more specific method matches describe() as dispatcher -> shape as Shape <- rtn as String?
Fixed: Give the dispatcher entry point a body: it runs when no more specific method matches
#!ek9 defines module error.e07120.good.fix defines class Shape as open kind() <- rtn as String: "shape" Describer //The entry point is what runs when no more specific method matches describe() as dispatcher -> shape as Shape <- rtn as String: shape.kind()
Fixed: Give the dispatcher entry point a body
#!ek9 defines module error.e07120.good defines class Shape as open kind() <- rtn as String: "shape" Circle extends Shape override kind() <- rtn as String: "circle" Describer //The entry point has a body: the fallback for any Shape describe() -> circle as Circle <- rtn as String: "a round " + circle.kind() describe() as dispatcher -> shape as Shape <- rtn as String: "some " + shape.kind() //Chosen at run time when the Shape is a Circle
Questions and answers
These Q&A entries show E07120 and its fix:
Found a problem?
If EK9 reported E07120 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.