]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use g_object_class_override_property to implement generic interface properties
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 13 Mar 2023 08:13:34 +0000 (09:13 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 13 Mar 2023 08:13:34 +0000 (09:13 +0100)
This caused the criticals like:

    GLib-GObject-CRITICAL **: Read/writable property 'data' on class 'Foo' has type
    'gchararray' which is not exactly equal to the type 'gpointer' of the property on
    the interface 'IFoo'

Fixes https://gitlab.gnome.org/GNOME/vala/issues/1419

codegen/valagobjectmodule.vala
tests/Makefile.am
tests/generics/interface-property-impl.c-expected [new file with mode: 0644]
tests/generics/interface-property-impl.vala [new file with mode: 0644]

index 457e7f2de4f89ce31772fa55639cc162cca1a34d..e2179f1f49ddfa1b1686120ccbfc5b7378ec6d0d 100644 (file)
@@ -142,12 +142,28 @@ public class Vala.GObjectModule : GTypeModule {
                                ccode.add_statement (new CCodeComment (prop.comment.content));
                        }
 
-                       var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
+                       var cinst = new CCodeFunctionCall ();
                        cinst.add_argument (ccall);
                        cinst.add_argument (new CCodeConstant ("%s_PROPERTY".printf (get_ccode_upper_case_name (prop))));
-                       cinst.add_argument (get_param_spec (prop));
 
-                       ccode.add_expression (cinst);
+                       //TODO g_object_class_override_property should be used more regulary
+                       unowned Property? base_prop = prop.base_interface_property;
+                       if (base_prop != null && base_prop.property_type is GenericType) {
+                               cinst.call = new CCodeIdentifier ("g_object_class_override_property");
+                               cinst.add_argument (get_property_canonical_cconstant (prop));
+
+                               ccode.add_expression (cinst);
+
+                               var cfind = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_find_property"));
+                               cfind.add_argument (ccall);
+                               cfind.add_argument (get_property_canonical_cconstant (prop));
+                               ccode.add_expression (new CCodeAssignment (get_param_spec_cexpression (prop), cfind));
+                       } else {
+                               cinst.call = new CCodeIdentifier ("g_object_class_install_property");
+                               cinst.add_argument (get_param_spec (prop));
+
+                               ccode.add_expression (cinst);
+                       }
                }
        }
 
index b21e414c883739d91f581af9d1310840c9d309bf..80f659c9ec0035d9e5189ef3c726accefdf295d7 100644 (file)
@@ -800,6 +800,7 @@ TESTS = \
        generics/integer-member-access.vala \
        generics/integer-type-cast.vala \
        generics/integer-type-cast-return.vala \
+       generics/interface-property-impl.vala \
        generics/parameter-invalid-initializer.test \
        generics/parameter-in-cast.vala \
        generics/parameter-out-cast.vala \
diff --git a/tests/generics/interface-property-impl.c-expected b/tests/generics/interface-property-impl.c-expected
new file mode 100644 (file)
index 0000000..1ea2e38
--- /dev/null
@@ -0,0 +1,521 @@
+/* generics_interface_property_impl.c generated by valac, the Vala compiler
+ * generated from generics_interface_property_impl.vala, do not modify */
+
+#include <glib-object.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !defined(VALA_EXTERN)
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define VALA_EXTERN __declspec(dllexport) extern
+#elif __GNUC__ >= 4
+#define VALA_EXTERN __attribute__((visibility("default"))) extern
+#else
+#define VALA_EXTERN extern
+#endif
+#endif
+
+#define TYPE_IFOO (ifoo_get_type ())
+#define IFOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IFOO, IFoo))
+#define IS_IFOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IFOO))
+#define IFOO_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_IFOO, IFooIface))
+
+typedef struct _IFoo IFoo;
+typedef struct _IFooIface IFooIface;
+
+#define TYPE_FOO (foo_get_type ())
+#define FOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOO, Foo))
+#define FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOO, FooClass))
+#define IS_FOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOO))
+#define IS_FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOO))
+#define FOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOO, FooClass))
+
+typedef struct _Foo Foo;
+typedef struct _FooClass FooClass;
+typedef struct _FooPrivate FooPrivate;
+enum  {
+       FOO_0_PROPERTY,
+       FOO_DATA_PROPERTY,
+       FOO_NUM_PROPERTIES
+};
+static GParamSpec* foo_properties[FOO_NUM_PROPERTIES];
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+#define TYPE_BAR (bar_get_type ())
+#define BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BAR, Bar))
+#define BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BAR, BarClass))
+#define IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BAR))
+#define IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BAR))
+#define BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BAR, BarClass))
+
+typedef struct _Bar Bar;
+typedef struct _BarClass BarClass;
+typedef struct _BarPrivate BarPrivate;
+enum  {
+       BAR_0_PROPERTY,
+       BAR_DATA_PROPERTY,
+       BAR_NUM_PROPERTIES
+};
+static GParamSpec* bar_properties[BAR_NUM_PROPERTIES];
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
+
+struct _IFooIface {
+       GTypeInterface parent_iface;
+       gconstpointer (*get_data) (IFoo* self);
+       void (*set_data) (IFoo* self, gconstpointer value);
+};
+
+struct _Foo {
+       GObject parent_instance;
+       FooPrivate * priv;
+};
+
+struct _FooClass {
+       GObjectClass parent_class;
+};
+
+struct _FooPrivate {
+       gchar* _data;
+};
+
+struct _Bar {
+       GObject parent_instance;
+       BarPrivate * priv;
+};
+
+struct _BarClass {
+       GObjectClass parent_class;
+};
+
+struct _BarPrivate {
+       gint _data;
+};
+
+static gint Foo_private_offset;
+static gpointer foo_parent_class = NULL;
+static IFooIface * foo_ifoo_parent_iface = NULL;
+static gint Bar_private_offset;
+static gpointer bar_parent_class = NULL;
+static IFooIface * bar_ifoo_parent_iface = NULL;
+
+VALA_EXTERN GType ifoo_get_type (void) G_GNUC_CONST ;
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (IFoo, g_object_unref)
+VALA_EXTERN gconstpointer ifoo_get_data (IFoo* self);
+VALA_EXTERN void ifoo_set_data (IFoo* self,
+                    gconstpointer value);
+static GType ifoo_get_type_once (void);
+VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ;
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (Foo, g_object_unref)
+VALA_EXTERN Foo* foo_new (void);
+VALA_EXTERN Foo* foo_construct (GType object_type);
+static void foo_finalize (GObject * obj);
+static GType foo_get_type_once (void);
+static void _vala_foo_get_property (GObject * object,
+                             guint property_id,
+                             GValue * value,
+                             GParamSpec * pspec);
+static void _vala_foo_set_property (GObject * object,
+                             guint property_id,
+                             const GValue * value,
+                             GParamSpec * pspec);
+VALA_EXTERN GType bar_get_type (void) G_GNUC_CONST ;
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (Bar, g_object_unref)
+VALA_EXTERN Bar* bar_new (void);
+VALA_EXTERN Bar* bar_construct (GType object_type);
+static void bar_finalize (GObject * obj);
+static GType bar_get_type_once (void);
+static void _vala_bar_get_property (GObject * object,
+                             guint property_id,
+                             GValue * value,
+                             GParamSpec * pspec);
+static void _vala_bar_set_property (GObject * object,
+                             guint property_id,
+                             const GValue * value,
+                             GParamSpec * pspec);
+static void _vala_main (void);
+
+gconstpointer
+ifoo_get_data (IFoo* self)
+{
+       IFooIface* _iface_;
+       g_return_val_if_fail (IS_IFOO (self), NULL);
+       _iface_ = IFOO_GET_INTERFACE (self);
+       if (_iface_->get_data) {
+               return _iface_->get_data (self);
+       }
+       return NULL;
+}
+
+void
+ifoo_set_data (IFoo* self,
+               gconstpointer value)
+{
+       IFooIface* _iface_;
+       g_return_if_fail (IS_IFOO (self));
+       _iface_ = IFOO_GET_INTERFACE (self);
+       if (_iface_->set_data) {
+               _iface_->set_data (self, value);
+       }
+}
+
+static void
+ifoo_default_init (IFooIface * iface,
+                   gpointer iface_data)
+{
+       g_object_interface_install_property (iface, g_param_spec_pointer ("data", "data", "data", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
+}
+
+static GType
+ifoo_get_type_once (void)
+{
+       static const GTypeInfo g_define_type_info = { sizeof (IFooIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ifoo_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
+       GType ifoo_type_id;
+       ifoo_type_id = g_type_register_static (G_TYPE_INTERFACE, "IFoo", &g_define_type_info, 0);
+       g_type_interface_add_prerequisite (ifoo_type_id, G_TYPE_OBJECT);
+       return ifoo_type_id;
+}
+
+GType
+ifoo_get_type (void)
+{
+       static volatile gsize ifoo_type_id__once = 0;
+       if (g_once_init_enter (&ifoo_type_id__once)) {
+               GType ifoo_type_id;
+               ifoo_type_id = ifoo_get_type_once ();
+               g_once_init_leave (&ifoo_type_id__once, ifoo_type_id);
+       }
+       return ifoo_type_id__once;
+}
+
+static inline gpointer
+foo_get_instance_private (Foo* self)
+{
+       return G_STRUCT_MEMBER_P (self, Foo_private_offset);
+}
+
+Foo*
+foo_construct (GType object_type)
+{
+       Foo * self = NULL;
+       self = (Foo*) g_object_new (object_type, NULL);
+       return self;
+}
+
+Foo*
+foo_new (void)
+{
+       return foo_construct (TYPE_FOO);
+}
+
+static const gchar*
+foo_real_get_data (IFoo* base)
+{
+       const gchar* result;
+       Foo* self;
+       const gchar* _tmp0_;
+       self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FOO, Foo);
+       _tmp0_ = self->priv->_data;
+       result = _tmp0_;
+       return result;
+}
+
+static void
+foo_real_set_data (IFoo* base,
+                   const gchar* value)
+{
+       Foo* self;
+       gchar* old_value;
+       self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FOO, Foo);
+       old_value = foo_real_get_data (base);
+       if (g_strcmp0 (value, old_value) != 0) {
+               gchar* _tmp0_;
+               _tmp0_ = g_strdup (value);
+               _g_free0 (self->priv->_data);
+               self->priv->_data = _tmp0_;
+               g_object_notify_by_pspec ((GObject *) self, foo_properties[FOO_DATA_PROPERTY]);
+       }
+}
+
+static void
+foo_class_init (FooClass * klass,
+                gpointer klass_data)
+{
+       foo_parent_class = g_type_class_peek_parent (klass);
+       g_type_class_adjust_private_offset (klass, &Foo_private_offset);
+       G_OBJECT_CLASS (klass)->get_property = _vala_foo_get_property;
+       G_OBJECT_CLASS (klass)->set_property = _vala_foo_set_property;
+       G_OBJECT_CLASS (klass)->finalize = foo_finalize;
+       g_object_class_override_property (G_OBJECT_CLASS (klass), FOO_DATA_PROPERTY, "data");
+       foo_properties[FOO_DATA_PROPERTY] = g_object_class_find_property (G_OBJECT_CLASS (klass), "data");
+}
+
+static void
+foo_ifoo_interface_init (IFooIface * iface,
+                         gpointer iface_data)
+{
+       foo_ifoo_parent_iface = g_type_interface_peek_parent (iface);
+       iface->get_data = foo_real_get_data;
+       iface->set_data = foo_real_set_data;
+}
+
+static void
+foo_instance_init (Foo * self,
+                   gpointer klass)
+{
+       self->priv = foo_get_instance_private (self);
+}
+
+static void
+foo_finalize (GObject * obj)
+{
+       Foo * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOO, Foo);
+       _g_free0 (self->priv->_data);
+       G_OBJECT_CLASS (foo_parent_class)->finalize (obj);
+}
+
+static GType
+foo_get_type_once (void)
+{
+       static const GTypeInfo g_define_type_info = { sizeof (FooClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) foo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Foo), 0, (GInstanceInitFunc) foo_instance_init, NULL };
+       static const GInterfaceInfo ifoo_info = { (GInterfaceInitFunc) foo_ifoo_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
+       GType foo_type_id;
+       foo_type_id = g_type_register_static (G_TYPE_OBJECT, "Foo", &g_define_type_info, 0);
+       g_type_add_interface_static (foo_type_id, TYPE_IFOO, &ifoo_info);
+       Foo_private_offset = g_type_add_instance_private (foo_type_id, sizeof (FooPrivate));
+       return foo_type_id;
+}
+
+GType
+foo_get_type (void)
+{
+       static volatile gsize foo_type_id__once = 0;
+       if (g_once_init_enter (&foo_type_id__once)) {
+               GType foo_type_id;
+               foo_type_id = foo_get_type_once ();
+               g_once_init_leave (&foo_type_id__once, foo_type_id);
+       }
+       return foo_type_id__once;
+}
+
+static void
+_vala_foo_get_property (GObject * object,
+                        guint property_id,
+                        GValue * value,
+                        GParamSpec * pspec)
+{
+       Foo * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOO, Foo);
+       switch (property_id) {
+               case FOO_DATA_PROPERTY:
+               g_value_set_string (value, (gchar*) ifoo_get_data (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_IFOO, IFoo)));
+               break;
+               default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static void
+_vala_foo_set_property (GObject * object,
+                        guint property_id,
+                        const GValue * value,
+                        GParamSpec * pspec)
+{
+       Foo * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOO, Foo);
+       switch (property_id) {
+               case FOO_DATA_PROPERTY:
+               ifoo_set_data (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_IFOO, IFoo), g_value_get_string (value));
+               break;
+               default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static inline gpointer
+bar_get_instance_private (Bar* self)
+{
+       return G_STRUCT_MEMBER_P (self, Bar_private_offset);
+}
+
+Bar*
+bar_construct (GType object_type)
+{
+       Bar * self = NULL;
+       self = (Bar*) g_object_new (object_type, NULL);
+       return self;
+}
+
+Bar*
+bar_new (void)
+{
+       return bar_construct (TYPE_BAR);
+}
+
+static gint
+bar_real_get_data (IFoo* base)
+{
+       gint result;
+       Bar* self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_BAR, Bar);
+       result = self->priv->_data;
+       return result;
+}
+
+static void
+bar_real_set_data (IFoo* base,
+                   gint value)
+{
+       Bar* self;
+       gint old_value;
+       self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_BAR, Bar);
+       old_value = bar_real_get_data (base);
+       if (old_value != value) {
+               self->priv->_data = value;
+               g_object_notify_by_pspec ((GObject *) self, bar_properties[BAR_DATA_PROPERTY]);
+       }
+}
+
+static void
+bar_class_init (BarClass * klass,
+                gpointer klass_data)
+{
+       bar_parent_class = g_type_class_peek_parent (klass);
+       g_type_class_adjust_private_offset (klass, &Bar_private_offset);
+       G_OBJECT_CLASS (klass)->get_property = _vala_bar_get_property;
+       G_OBJECT_CLASS (klass)->set_property = _vala_bar_set_property;
+       G_OBJECT_CLASS (klass)->finalize = bar_finalize;
+       g_object_class_override_property (G_OBJECT_CLASS (klass), BAR_DATA_PROPERTY, "data");
+       bar_properties[BAR_DATA_PROPERTY] = g_object_class_find_property (G_OBJECT_CLASS (klass), "data");
+}
+
+static void
+bar_ifoo_interface_init (IFooIface * iface,
+                         gpointer iface_data)
+{
+       bar_ifoo_parent_iface = g_type_interface_peek_parent (iface);
+       iface->get_data = bar_real_get_data;
+       iface->set_data = bar_real_set_data;
+}
+
+static void
+bar_instance_init (Bar * self,
+                   gpointer klass)
+{
+       self->priv = bar_get_instance_private (self);
+}
+
+static void
+bar_finalize (GObject * obj)
+{
+       Bar * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BAR, Bar);
+       G_OBJECT_CLASS (bar_parent_class)->finalize (obj);
+}
+
+static GType
+bar_get_type_once (void)
+{
+       static const GTypeInfo g_define_type_info = { sizeof (BarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Bar), 0, (GInstanceInitFunc) bar_instance_init, NULL };
+       static const GInterfaceInfo ifoo_info = { (GInterfaceInitFunc) bar_ifoo_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
+       GType bar_type_id;
+       bar_type_id = g_type_register_static (G_TYPE_OBJECT, "Bar", &g_define_type_info, 0);
+       g_type_add_interface_static (bar_type_id, TYPE_IFOO, &ifoo_info);
+       Bar_private_offset = g_type_add_instance_private (bar_type_id, sizeof (BarPrivate));
+       return bar_type_id;
+}
+
+GType
+bar_get_type (void)
+{
+       static volatile gsize bar_type_id__once = 0;
+       if (g_once_init_enter (&bar_type_id__once)) {
+               GType bar_type_id;
+               bar_type_id = bar_get_type_once ();
+               g_once_init_leave (&bar_type_id__once, bar_type_id);
+       }
+       return bar_type_id__once;
+}
+
+static void
+_vala_bar_get_property (GObject * object,
+                        guint property_id,
+                        GValue * value,
+                        GParamSpec * pspec)
+{
+       Bar * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BAR, Bar);
+       switch (property_id) {
+               case BAR_DATA_PROPERTY:
+               g_value_set_int (value, (gint) ((gintptr) ifoo_get_data (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_IFOO, IFoo))));
+               break;
+               default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static void
+_vala_bar_set_property (GObject * object,
+                        guint property_id,
+                        const GValue * value,
+                        GParamSpec * pspec)
+{
+       Bar * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BAR, Bar);
+       switch (property_id) {
+               case BAR_DATA_PROPERTY:
+               ifoo_set_data (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_IFOO, IFoo), (gpointer) ((gintptr) g_value_get_int (value)));
+               break;
+               default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static void
+_vala_main (void)
+{
+       {
+               Foo* foo = NULL;
+               Foo* _tmp0_;
+               gconstpointer _tmp1_;
+               gconstpointer _tmp2_;
+               _tmp0_ = foo_new ();
+               foo = _tmp0_;
+               ifoo_set_data (G_TYPE_CHECK_INSTANCE_CAST (foo, TYPE_IFOO, IFoo), "foo");
+               _tmp1_ = ifoo_get_data (G_TYPE_CHECK_INSTANCE_CAST (foo, TYPE_IFOO, IFoo));
+               _tmp2_ = _tmp1_;
+               _vala_assert (g_strcmp0 ((const gchar*) _tmp2_, "foo") == 0, "foo.data == \"foo\"");
+               _g_object_unref0 (foo);
+       }
+       {
+               Bar* bar = NULL;
+               Bar* _tmp3_;
+               gconstpointer _tmp4_;
+               gconstpointer _tmp5_;
+               _tmp3_ = bar_new ();
+               bar = _tmp3_;
+               ifoo_set_data (G_TYPE_CHECK_INSTANCE_CAST (bar, TYPE_IFOO, IFoo), (gpointer) ((gintptr) 42));
+               _tmp4_ = ifoo_get_data (G_TYPE_CHECK_INSTANCE_CAST (bar, TYPE_IFOO, IFoo));
+               _tmp5_ = _tmp4_;
+               _vala_assert (((gint) ((gintptr) _tmp5_)) == 42, "bar.data == 42");
+               _g_object_unref0 (bar);
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main ();
+       return 0;
+}
+
diff --git a/tests/generics/interface-property-impl.vala b/tests/generics/interface-property-impl.vala
new file mode 100644 (file)
index 0000000..38f439c
--- /dev/null
@@ -0,0 +1,24 @@
+interface IFoo<T> : Object {
+       public abstract T data { get; set; }
+}
+
+class Foo : Object, IFoo<string> {
+       public string data { get; set; }
+}
+
+class Bar : Object, IFoo<int> {
+       public int data { get; set; }
+}
+
+void main () {
+       {
+               var foo = new Foo ();
+               foo.data = "foo";
+               assert (foo.data == "foo");
+       }
+       {
+               var bar = new Bar ();
+               bar.data = 42;
+               assert (bar.data == 42);
+       }
+}