[vala/0.46] codegen: Don't set implemenation of interface property to its own
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] codegen: Don't set implemenation of interface property to its own
- Date: Wed, 5 Feb 2020 10:03:26 +0000 (UTC)
commit 0dbf0f353b86863dd9666ceee7c3544102d02343
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jan 7 17:20:25 2020 +0100
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
codegen/valagtypemodule.vala | 5 +++++
tests/Makefile.am | 1 +
tests/objects/interface-property-base-impl.vala | 16 ++++++++++++++++
3 files changed, 22 insertions(+)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 20df1fbe0..3cf797526 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1542,6 +1542,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 ce92b0d17..df500ac58 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -335,6 +335,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);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]