Override in inheritance chain
Posted: Fri Apr 16, 2021 7:25 pm
Hi,
I have experienced some very unexpected and annoying behavior when dealing with an inheritance chain and a method that is supposed to be override in both subclasses. Here is a simple example:
Even if I additionally mark as overridable in SC1 so that it is marked as override AND overridable at the same time (which is possible), I get the same behavior.
Is this intended?
I have experienced some very unexpected and annoying behavior when dealing with an inheritance chain and a method that is supposed to be override in both subclasses. Here is a simple example:
Code: Select all
:class BC
∇ sayHello
:access public overridable
'I'm the base class.'
∇
∇ speak
:access public
sayHello
∇
:endclass
:class SC1 : BC
∇ sayHello
:access public override
'I'm the first subclass.'
∇
:endclass
:class SC2 : SC1
∇ sayHello
:access public override
'I'm the second subclass.'
∇
:endclass
Code: Select all
inst←⎕new SC2
inst.speak
⍝ inst says "I'm the first subclass."
⍝ Intuitively, I would expect "I'm the second subclass.", which is also what you would get in other programming languages.
Even if I additionally mark
Code: Select all
sayHello
Is this intended?