summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-01-21 17:56:28 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2020-01-21 18:01:18 +0100
commit04806bb5df09f07aab7903222ecee2244c7a9f70 (patch)
tree0646ea4cfc05c6ed0c23abea1905918a95af7349
parented421a9aa362d48f778e4a8e22f1d4a763d6beea (diff)
downloadvala-04806bb5df09f07aab7903222ecee2244c7a9f70.tar.gz
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
-rw-r--r--codegen/valaccodebasemodule.vala5
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/objects/member-initializer-base-properties.vala19
3 files changed, 25 insertions, 0 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 932228eb5..1e0bfb4e2 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5024,6 +5024,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 = SemanticAnalyzer.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 c3b44aa7f..24f9d1622 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -354,6 +354,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"
+ };
+}