After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 678065 - Overriding construct-only properties not supported
Overriding construct-only properties not supported
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator
0.16.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-06-14 05:13 UTC by Tristan Brindle
Modified: 2018-05-22 14:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tristan Brindle 2012-06-14 05:13:06 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.
Comment 1 GNOME Infrastructure Team 2018-05-22 14:26:53 UTC
-- 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.