Push Down
Push Down relocates a method or operator from a superclass into the subclasses you choose: removed from the superclass, copied into each one picked. Here fly() is declared on Bird, but a Penguin cannot fly - only Eagle should keep it. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide -lesson push-down.
Start from
The code the lesson starts from: copy it into a file of your own and follow the steps.
#!ek9 defines module lesson.birds defines class Bird as open fly() as pure <- rtn as String: "soaring through the sky" Eagle extends Bird Penguin extends Bird defines program Birds() stdout <- Stdout() eagle <- Eagle() stdout.println(eagle.fly()) //EOF
Step 1: Where it is
Put the caret on fly, on line 8.
Step 2: Push Down
Right-click it - or choose Refactor > Refactor This… - and choose Push 'fly' Down…
Tick Eagle only - Penguin stays without fly() - and choose Preview.
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 Push Down: fly() is gone from Bird and lives on Eagle alone; Penguin has none at all. A caller that reached the member through the superclass type, or a subclass left out that still needed it, surfaces in the preview instead of a silent wrong move. It is on the right-click menu wherever the caret is on a method or operator of a class with direct subclasses; AI assistants use the ek9_push_down tool.
Where this lesson comes from
- For AI assistants - the MCP tool
ek9_push_down.





