]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't set implemenation of interface property to its own ce690e98c96aa610408bf23512acf93ec38990ee
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 7 Jan 2020 16:20:25 +0000 (17:20 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 7 Jan 2020 16:39:03 +0000 (17:39 +0100)
A base-class is allowed to provide interface implementations for methods
and properties. If those exist without an explicit implementation in the
sub-class we then we end up finding the interface property itself. Using
that is obviously wrong and causes a cyclic call stack.

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

codegen/valagtypemodule.vala
tests/Makefile.am
tests/objects/interface-property-base-impl.vala [new file with mode: 0644]

index 153128ac61534f36bf713b0a64a1618bfeb22c79..17c0690b3fc6c57e4fe749cb1d69b4b8fb2119b3 100644 (file)
@@ -1559,6 +1559,11 @@ public class Vala.GTypeModule : GErrorModule {
                                        base_property = cl_prop.base_interface_property;
                                }
 
+                               // Our base class provides this interface implementation
+                               if (prop == base_property) {
+                                       continue;
+                               }
+
                                var ciface = new CCodeIdentifier ("iface");
 
                                if (base_property.get_accessor != null && prop.get_accessor != null) {
index ebeeed0efdec759c083a29ef8c8572b55eac7170..a486591ecb9ad4d1a43dfa9af4f526ee6beb5583 100644 (file)
@@ -343,6 +343,7 @@ TESTS = \
        objects/interfaces.vala \
        objects/interface-generics.vala \
        objects/interface-property-base-access.vala \
+       objects/interface-property-base-impl.vala \
        objects/interface-property-delegate.vala \
        objects/interface-property-override.vala \
        objects/interface-virtual-override.vala \
diff --git a/tests/objects/interface-property-base-impl.vala b/tests/objects/interface-property-base-impl.vala
new file mode 100644 (file)
index 0000000..21988c3
--- /dev/null
@@ -0,0 +1,16 @@
+public interface IFoo : Object {
+    public abstract int prop { get; set; }
+}
+
+public class Foo : Object, IFoo {
+    public int prop { get; set; }
+}
+
+public class Bar : Foo, IFoo {
+}
+
+void main (){
+    IFoo bar = new Bar ();
+    bar.prop = 42;
+    assert (bar.prop == 42);
+}