GNOME Bugzilla – Bug 764481
[PATCH] Invalid code generation on set parent class property in overridden property
Last modified: 2017-03-09 06:56:12 UTC
The following code: struct Test { int a; } class Master : GLib.Object { public virtual Test prop { get; set; } } class Child : Master { public override Test prop { get { return base.prop; } set { base.prop = value; } } } static void main () { Child child = new Child (); child.prop.a = 10; } generates invalid C code which fails on build with following error: test.vala.c: In function ‘child_real_get_prop’: test.vala.c:15:29: error: too few arguments to function ‘((MasterClass *)g_type_check_class_cast((GTypeClass *)child_parent_class, master_get_type()))->get_prop’ #define MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MASTER, MasterClass)) ^ test.vala.c:248:11: note: in expansion of macro ‘MASTER_CLASS’ _tmp0_ = MASTER_CLASS (child_parent_class)->get_prop (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_MASTER, Master)); ^ test.vala.c: In function ‘child_real_set_prop’: test.vala.c:259:103: error: incompatible type for argument 2 of ‘((MasterClass *)g_type_check_class_cast((GTypeClass *)child_parent_class, master_get_type()))->set_prop’ MASTER_CLASS (child_parent_class)->set_prop (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_MASTER, Master), _tmp0_); ^ test.vala.c:259:103: note: expected ‘Test * {aka struct _Test *}’ but argument is of type ‘Test {aka struct _Test}’ error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) The attached patch fix the access of base property in overridden set when time was a boxed type
Created attachment 325190 [details] [review] fix base access in overridden property
Created attachment 347507 [details] [review] codegen: Fix base-access from within overriding property-accessor Based on patch by gandalfn
Created attachment 347508 [details] [review] codegen: Fix base-access from within overriding struct-property-accessor Based on patch by gandalfn
working fine, in my side thanks
Attachment 347508 [details] pushed as 38593b2 - codegen: Fix base-access from within overriding struct-property-accessor