From: Rico Tzschichholz Date: Tue, 7 Jan 2020 16:20:25 +0000 (+0100) Subject: codegen: Don't set implemenation of interface property to its own X-Git-Tag: 0.47.3~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce690e98c96aa610408bf23512acf93ec38990ee;p=thirdparty%2Fvala.git codegen: Don't set implemenation of interface property to its own 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 --- diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 153128ac6..17c0690b3 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -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) { diff --git a/tests/Makefile.am b/tests/Makefile.am index ebeeed0ef..a486591ec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..21988c39c --- /dev/null +++ b/tests/objects/interface-property-base-impl.vala @@ -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); +}