[Vala] implementing interface properties through inheritance



When an interface declares a property, and a class implementing that interface inherits from a class that implements a property of the same name, what should happen?

Here is some Vala code that explicitly implements the interface property by calling up to the base class. With [NoAccessorMethod], Vala needs to use g_object_get() to get the property by name. But what property will it get? Unfortunately, it just seg faults. If I omit [NoAccessorMethod], Vala gets the field directly, and everything works as expected (the base property is retrieved).  So if Base is defined in an external library (brought in via vapi), and there's no accessor methods (and even if there were, they might use g_object_get/set), what should be done in this case?

public interface Interface {
  public abstract bool prop { get; set construct; }
}

public class Base : Object {
  [NoAccessorMethod]
  public bool prop { get; set construct; default = true; }
}

public class Child : Base, Interface {
  public bool prop {
    get { return base.prop; }
    set construct { base.prop = value; }
  }
  public static void main(string[] args) {
    Child child = new Child();
    if (child.prop)
      debug("from base");
  }
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]