#1677 js: override error with virtual methods in mixins

jessevdam Tue 25 Oct 2011

I have the following classes

mixin Panel
{
  virtual Void requestCommentRect(|CommentRect?| func)
  {
    //empty function
  }
}

abstract class NetworkViewBase : SvgPane,Panel
{
  override Void requestCommentRect(|CommentRect?| func)
  {
    //should be called
    requestCommentRectFunc = func
  }
}

class NetworkPanel : NetworkViewBase,Panel
{
}

When I now call the following it calls the empty function

obj.requestCommentRect(someVal) //obj instanceof NetworkPanel

When I check the generated JS code it looks like

...
fan.FlowerNet.Panel.prototype.requestCommentRect = function(func)
{
  return;
}
...
fan.FlowerNet.OverviewPane.prototype.requestCommentRect = fan.FlowerNet.Panel.prototype.requestCommentRect;
...
fan.FlowerNet.NetworkViewBase.prototype.requestCommentRect = function(func)
{ 
  this.m_requestCommentRectFunc = func;
  return;
}
...
fan.FlowerNet.NetworkPanel.prototype.requestCommentRect = fan.FlowerNet.Panel.prototype.requestCommentRect;

The last line in the JS should not be generated, since it is already defined. Note the NetworkPanel : NetworkViewBase,Panel and class NetworkViewBase : SvgPane,Panel

Remove ,Panel from NetworkPanel solves the problem, but still it should not have this behaviour. It should either give an error or the compiler should prevent already included mixins from being added to the AST.

andy Tue 25 Oct 2011

Renamed from JS: override error with virtual methods in mixins to js: override error with virtual methods in mixins

andy Tue 25 Oct 2011

Promoted to ticket #1677 and assigned to andy

Login or Signup to reply.