I get E05030 'not open to be extended'. What does this mean and how do I fix it?

← Debugging and Troubleshooting · Ref: Q1043

E05030 means you tried to extend a type that is closed. In EK9, ALL types are closed by default — they cannot be extended unless explicitly marked 'as open'.

Diagnosis steps:
1. Find the class you are trying to extend
2. Check if it has 'as open' in its declaration
3. If it does not, it is closed and cannot be extended

Fix option 1 — make the parent open (if you own it):

  BEFORE: MyBase
  AFTER:  MyBase as open

Fix option 2 — use composition instead (recommended):

  BEFORE: MyChild extends MyBase
  AFTER:  MyChild
            delegate as MyBase?

Composition is the preferred pattern in EK9. It avoids tight coupling and works with all types, including built-in types like List and Dict which are always closed.

Built-in types (List, Dict, Optional, Result) can NEVER be extended. Always use composition with these.

Run 'ek9 -h E05030' for the full compiler explanation.

See Q1044 for extending built-in types. See Q102 for the 'as open' modifier. See Q109 for composition patterns. See Q1027 for a design review using composition.

Example

defines module qa.debugging.diagnosee05030

  defines class

    //This class is open — it CAN be extended
    Vehicle as open
      speed <- Float()

      default Vehicle()

      accelerate()
        -> amount as Float
        speed :=? amount

      override operator ? as pure
        <- rtn as Boolean: speed?

      operator $ as pure
        <- rtn as String: "Vehicle"

    //This extends Vehicle — allowed because Vehicle is open
    Car is Vehicle
      brand as String?

      default private Car()

      Car()
        -> brand as String
        this.brand: brand

      override operator ? as pure
        <- rtn as Boolean: brand?

      override operator $ as pure
        <- rtn as String: `${brand} car`

  defines program

    DiagnoseE05030Demo()
      stdout <- Stdout()

      car <- Car("Ford")
      car.accelerate(60.0)
      stdout.println(`${car}`)

Common mistakes

E05030 — Removing 'as open' makes Vehicle a closed type (EK9 types are closed by default), so 'Car is Vehicle' is rejected as not open to be extended. See ek9 -h E05030 for details.

Incorrect:

Vehicle

Correct:

Vehicle as open
Other ways to ask this
  • Diagnose E05030: my class cannot be extended
  • The compiler says my type is not open. What is going on?
  • Why can't I extend this class? I get E05030

Coming from another language?

Java classes are open by default. EK9 classes are closed by default. Use 'as open' to opt in, or use composition instead.

Keywords: extend, investigate, E05030, closed, open, error, diagnose