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 654702 - Cannot chain up using gobject-style constructor to base class with generics
Cannot chain up using gobject-style constructor to base class with generics
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GObject
0.13.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-07-15 21:02 UTC by Travis Reitter
Modified: 2011-07-16 07:13 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Travis Reitter 2011-07-15 21:02:38 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;
}
Comment 1 Luca Bruno 2011-07-15 21:12:55 UTC
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 ();
}
Comment 2 Luca Bruno 2011-07-16 07:13:10 UTC
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.