[vala/staging: 6/6] 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/staging: 6/6] codegen: Don't set implemenation of interface property to its own
- Date: Tue, 7 Jan 2020 16:39:47 +0000 (UTC)
commit ce690e98c96aa610408bf23512acf93ec38990ee
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 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);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]