GNOME Bugzilla – Bug 654702
Cannot chain up using gobject-style constructor to base class with generics
Last modified: 2011-07-16 07:13:10 UTC
I ran into the following incorrect C code for this snippet of Vala: public abstract class Folks.AbstractFieldDetails<T> : Object { private T _value; public virtual T @value { get { return this._value; } set { this._value = value; } } ... } public class Folks.FieldDetails : AbstractFieldDetails<string> { public FieldDetails (string value) { Object (value: value); } ... ================ Generated C: FolksFieldDetails* folks_field_details_construct (GType object_type, const gchar* value) { FolksFieldDetails * self = NULL; g_return_val_if_fail (value != NULL, NULL); // XXX: note that G_TYPE_STRING through g_free should not be there, which causes this to segfault accessing 0x40 (G_TYPE_STRING) as a string self = (FolksFieldDetails*) g_object_new (object_type, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, "value", value, NULL); return self; }
Thanks for the bug report. The bug is about chaining up to gobject-style constructor of a base class having type parameters, which is unrelated to the virtual generic property: class Foo<T> : Object { } class Bar : Foo<string> { public Bar () { Object (); } } void main () { new Bar (); }
commit a4af16f9e0f18f1ac4b33943c482de6b2bc63edd Author: Luca Bruno <lucabru@src.gnome.org> Date: Sat Jul 16 09:02:38 2011 +0200 codegen: Support gobject-style chainup to base class that has generics Fixes bug 654702. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.