C# property overloading in haxe

57 views
Skip to first unread message

Roman Mikhailov

unread,
May 20, 2015, 6:13:41 PM5/20/15
to haxe...@googlegroups.com
Hi!

In C# librabry I have class with abstract property. I need extend this class in haxe. How can I override this property? Example:

abstract class Base
{
  public virtual int x
  {
    get { throw new NotImplementedException(); }
  }
}

class Child extends Base
{
  public var x(default, null):Int; // Doesn't work. Haxe compiler: Redefinition of variable x in subclass is not allowed. Previously declared at Base

  
public var x(default, never):Int; // Doesn't work. Haxe compiler: Redefinition of variable x in subclass is not allowed. Previously declared at Base

  public var x(get, null):Int; // Doesn't work. Haxe compiler: Redefinition of variable x in subclass is not allowed. Previously declared at Base
  
  public function get_x():Int
  {
    return 0;
  }
}


Roman Mikhailov

unread,
May 21, 2015, 6:09:29 AM5/21/15
to haxe...@googlegroups.com

Found solution:
For example we have next C# class:

abstract class Base
{
 public abstract int Foo
 {
   get;
 }
}




in Haxe we should:
class Child extends Base
{
 @:overload
 override public function get_Foo():Int
 {
   return <some Int value>;
 }
}



четверг, 21 мая 2015 г., 1:13:41 UTC+3 пользователь Roman Mikhailov написал:
Reply all
Reply to author
Forward
0 new messages