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 764481 - [PATCH] Invalid code generation on set parent class property in overridden property
[PATCH] Invalid code generation on set parent class property in overridden pr...
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GObject
0.35.x
Other Linux
: Normal critical
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-04-01 21:14 UTC by gandalfn
Modified: 2017-03-09 06:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix base access in overridden property (4.76 KB, patch)
2016-04-01 21:17 UTC, gandalfn
none Details | Review
codegen: Fix base-access from within overriding property-accessor (6.94 KB, patch)
2017-03-08 21:56 UTC, Rico Tzschichholz
none Details | Review
codegen: Fix base-access from within overriding struct-property-accessor (6.33 KB, patch)
2017-03-08 22:02 UTC, Rico Tzschichholz
committed Details | Review

Description gandalfn 2016-04-01 21:14:13 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
Comment 1 gandalfn 2016-04-01 21:17:17 UTC
Created attachment 325190 [details] [review]
fix base access in overridden property
Comment 2 Rico Tzschichholz 2017-03-08 21:56:42 UTC
Created attachment 347507 [details] [review]
codegen: Fix base-access from within overriding property-accessor

Based on patch by gandalfn
Comment 3 Rico Tzschichholz 2017-03-08 22:02:21 UTC
Created attachment 347508 [details] [review]
codegen: Fix base-access from within overriding struct-property-accessor

Based on patch by gandalfn
Comment 4 gandalfn 2017-03-08 22:13:37 UTC
working fine, in my side

thanks
Comment 5 Rico Tzschichholz 2017-03-09 06:55:09 UTC
Attachment 347508 [details] pushed as 38593b2 - codegen: Fix base-access from within overriding struct-property-accessor