E05030: not open to be extended

Category: E05xxx Explicit type symbol definition · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: NOT_OPEN_TO_EXTENSION · All error codes

What went wrong

You're trying to extend a class that isn't marked as 'open'. In EK9, classes are CLOSED by default - they cannot be extended unless explicitly designed for inheritance.

Worked examples

Compilable examples demonstrating this error and the correct fix:

How to fix it

  1. If you control BaseClass: add 'as open' if inheritance is intended
  2. If you don't control BaseClass: use composition (wrap the class)
  3. Consider if inheritance is really needed - composition is often better

Rationale

Classes closed by default because:

  • Prevents fragile base class problem (changes break subclasses)
  • Forces explicit design for inheritance (intentional extension points)
  • Encourages composition over inheritance (more flexible)
  • Makes class contracts more predictable (sealed behavior)

Common causes

  • Assuming classes are open like Java (EK9 defaults differ)
  • Forgetting to add 'as open' when designing for inheritance
  • Trying to extend built-in types (List, Dict, etc. - all closed)

See also

  • E05030: extending closed class (this error)
  • E05020: circular inheritance (different - cycle in hierarchy)

https://ek9.io/inheritance.html#closed-by-default https://ek9.io/forAI.json#$.closedByDefault

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E05030: not open to be extended

#!ek9
defines module error.e05030.bad

  defines class

    Shape
      describe()
        <- description as String: "a shape"

    Circle extends Shape
      override describe()
        <- description as String: "a circle"

Fixed: Open the type you mean to extend

#!ek9
defines module error.e05030.good

  defines class

    Shape as open
      describe()
        <- description as String: "a shape"

    Circle extends Shape
      override describe()
        <- description as String: "a circle"

Questions and answers

These Q&A entries show E05030 and its fix: