GNOME Bugzilla – Bug 683160
Link error with abstract construct property
Last modified: 2018-02-23 19:20:16 UTC
Implementing an abstract construct property in a different file from the one in which it is originally declared is not possible. Example: $ cat proptest_iface.vala public interface HasProperty : Object { public abstract string myprop { get; construct; } } $ cat proptest_impl.vala public abstract class ImplementsProperty : Object, HasProperty { public string myprop { get; construct; } } void main () { } $ valac-0.18 proptest_iface.vala proptest_impl.vala /home/tjol/tmp/proptest_impl.vala.c:65:13: warning: ‘has_property_set_myprop’ used but never defined [enabled by default] /tmp/ccCogCi2.o: In function `_vala_implements_property_set_property': proptest_impl.vala.c:(.text+0x42a): undefined reference to `has_property_set_myprop' collect2: ld returned 1 exit status error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) The reason for this is that the generated set method is static, which makes sense when the property declaration and constructor definition are in the same source file. For abstract properties, this can't be counted on. static void has_property_set_myprop (HasProperty* self, const gchar* value);
Thanks for your bug report. I'm glad to report that this has been fixed in the meantime: % valac --save-temps proptest_iface.vala proptest_impl.vala % grep has_property_set_myprop * Binary file proptest_iface matches proptest_iface.c:void has_property_set_myprop (HasProperty* self, proptest_iface.c:has_property_set_myprop (HasProperty* self, proptest_impl.c:void has_property_set_myprop (HasProperty* self, proptest_impl.c: has_property_set_myprop ((HasProperty*) self, g_value_get_string (value));