[vala/0.46] codegen: Cast instance parameter in member-initializer for base-properties
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] codegen: Cast instance parameter in member-initializer for base-properties
- Date: Wed, 5 Feb 2020 10:03:46 +0000 (UTC)
commit 85d49cd73217dc16b558c8e6dbf7eda39cf61c12
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jan 21 17:56:28 2020 +0100
codegen: Cast instance parameter in member-initializer for base-properties
This fixes warnings issued with -Wincompatible-pointer-types
Fixes https://gitlab.gnome.org/GNOME/vala/issues/899
codegen/valaccodebasemodule.vala | 5 +++++
tests/Makefile.am | 1 +
tests/objects/member-initializer-base-properties.vala | 19 +++++++++++++++++++
3 files changed, 25 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index a4ee7ebe2..3fd15f02b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5078,6 +5078,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
} else if (init.symbol_reference is Property) {
var p = (Property) init.symbol_reference;
+ if (p.base_property != null) {
+ p = p.base_property;
+ } else if (p.base_interface_property != null) {
+ p = p.base_interface_property;
+ }
var instance_target_type = get_data_type_for_symbol ((TypeSymbol)
p.parent_symbol);
var typed_inst = transform_value (new GLibValue (expr.type_reference,
instance), instance_target_type, init);
var inst_ma = new MemberAccess.simple ("fake");
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0fc59fb68..f83f58027 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -340,6 +340,7 @@ TESTS = \
objects/interface-property-delegate.vala \
objects/interface-property-override.vala \
objects/interface-virtual-override.vala \
+ objects/member-initializer-base-properties.vala \
objects/methods.vala \
objects/paramspec.vala \
objects/plugin-module-init.vala \
diff --git a/tests/objects/member-initializer-base-properties.vala
b/tests/objects/member-initializer-base-properties.vala
new file mode 100644
index 000000000..b21956d29
--- /dev/null
+++ b/tests/objects/member-initializer-base-properties.vala
@@ -0,0 +1,19 @@
+interface IFoo {
+ public abstract string prop { get; set; }
+}
+
+class Bar {
+ public virtual string prop_v { get; set; }
+}
+
+class Foo : Bar, IFoo {
+ public string prop { get; set; }
+ public override string prop_v { get; set; }
+}
+
+void main() {
+ var foo = new Foo () {
+ prop = "bar",
+ prop_v = "bar"
+ };
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]