Page 1 of 1

Override in inheritance chain

Posted: Fri Apr 16, 2021 7:25 pm
by zaibot.w
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:

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
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?

Re: Override in inheritance chain

Posted: Tue Apr 20, 2021 3:50 pm
by Vince|Dyalog
Hi zaibot.w,

I think this may be a bug, so I will add your example to this issue:

7625: Multiple levels of the class keyword Override do not work.

Regards,

Vince