Incompatible override when calling private super function

54 views
Skip to first unread message

Warren Eng

unread,
Nov 6, 2013, 8:25:15 PM11/6/13
to haxe...@googlegroups.com
I've encountered a peculiar behavior when generating AS3 source. When I override a private function and call its super function, the super class' function signature becomes public. I expect it to be protected. This causes a compile-time error:
Error: Incompatible override.

Here's a test case to reproduce the problem:
package;
class Foo
{
   
public function new()
   
{
   
}

   
private function someFunc():Bool
   
{
     
return false;
   
}
}

package;
class Bar extends Foo
{
   
public function new()
   
{
   
}

   
private override function someFunc():Bool
   
{
     
return super.someFunc();
   
}
}

The net result is that Foo now has:
public function someFunc():Bool
{
   
return false;
}

...and Bar now has:
protected override function someFunc():Bool
{
   
return super.someFunc();
}

Can anyone shed some light on what's going on here? Why does calling super.someFunc() modify the access to the parent class' someFunc()?

Reply all
Reply to author
Forward
0 new messages