E07250: component methods cannot be marked with the 'protected' access modifier
What went wrong
A method in a COMPONENT is marked 'protected'. Components don't support protected visibility.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 111 (What are components in EK9?)
How to fix it
- Use 'private' for internal methods
- Or use 'public' for external access
- Components don't support class inheritance patterns
Common causes
- Treating component like regular class
- Copy/paste from class code
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07250: component methods cannot be marked with the 'protected' access modifier
#!ek9 defines module error.e07250.bad defines component Store fetch() -> key as String <- rtn as String: normalise(key) //A component is never extended, so 'protected' means nothing here protected normalise() -> key as String <- rtn as String: key.trim()
Fixed: Make it private (or public)
#!ek9 defines module error.e07250.good defines component Store fetch() -> key as String <- rtn as String: normalise(key) private normalise() -> key as String <- rtn as String: key.trim()
Questions and answers
These Q&A entries show E07250 and its fix:
Found a problem?
If EK9 reported E07250 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.