GNOME Bugzilla – Bug 678065
Overriding construct-only properties not supported
Last modified: 2018-05-22 14:26:53 UTC
Trying to override construct-only properties always fails when the overriding implementation is in a different file to the original definition. This is the case both for interfaces and for base classes defining a virtual/abstract construct-only property. An example using an interface: File 1: public interface Test.Iface : Object { public abstract int prop { get; construct; } } File 2: public class Test.Impl : Object, Iface { public int prop { get; construct; } public Impl() { Object(prop: 3); } } void main() { new Test.Impl(); } (Replace the interface with a base class with a virtual property and the result is the same.) Vala compiles the code to C without warning, but the linker fails with the error "undefined reference to `test_iface_set_prop'". Looking at the generated C code, there are a couple of funny things going on. Firstly, the implementing class registers its property with g_object_class_install_property(), whereas idiomatic GObject would be to use g_object_class_override_property(). Secondly, the set_property() function in the implementing class calls test_iface_set_prop() (a static function in the interface C file, causing the error). I can't see any reason why it should go through this virtual function rather than calling its own test_impl_real_set_prop() version.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/307.