E08220: program uses injection but has no linked application
What went wrong
A program uses component injection (via '!' suffix) but has no linked application. Without an application, the compiler cannot know which concrete components to inject.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 672 (Why must programs declare 'with application of' for injec...)
How to fix it
- Add 'with application of <AppName>' to the program declaration
- Or remove the injection if DI is not needed
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E08220: program uses injection but has no linked application
#!ek9 defines module error.e08220.bad defines component AbstractService as abstract doWork() as abstract <- rtn as Boolean? default operator ? ConcreteService is AbstractService override doWork() <- rtn as Boolean: true default operator ? defines program noAppProgram() stdout <- Stdout() svc as AbstractService! if svc.doWork() stdout.println("test")
Fixed: Link the program to an application that registers the component
#!ek9 defines module error.e08220.good defines component AbstractService as abstract doWork() as abstract <- rtn as Boolean? default operator ? ConcreteService is AbstractService override doWork() <- rtn as Boolean: true default operator ? defines application serviceApp register ConcreteService() as AbstractService defines program appProgram() with application of serviceApp stdout <- Stdout() svc as AbstractService! if svc.doWork() stdout.println("test")
Questions and answers
These Q&A entries show E08220 and its fix: