Make Open

Change Modifier > Make Open adds 'as open' to a closed class, record, component or function, so it can be extended. EK9 types are closed by default - the opposite of most languages - so Shape cannot be extended until it says so; EK9 refuses Circle's attempt to extend it - E05030, explained in the Hovers panel. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide -lesson make-open.

The EK9 IDE as the lesson opens: the code to read and, in the Hovers panel, its error explained

Start from

The code the lesson starts from: copy it into a file of your own and follow the steps.

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"

Step 1: Where it is

Put the caret on Shape, on line 6.

The EK9 IDE once this is done: Put the caret on Shape, on line 6

Step 2: Make Open

Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Open.

The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Open

Step 3: Preview and apply

The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply.

The result

That is Make Open: Shape now says 'as open', so Circle extends it cleanly. Make Closed, Make Abstract and Make Concrete sit beside it in the same right-click Change Modifier submenu - the opposite narrowings. AI assistants use the ek9_make_open tool.

The EK9 IDE when the lesson has finished

Where this lesson comes from