[vala/0.40] 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.40] codegen: Cast instance parameter in member-initializer for base-properties
- Date: Wed, 5 Feb 2020 10:03:21 +0000 (UTC)
commit 2c825ae74355804ce5c2a7f648526fd423d5cee1
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 3e680afda..fb25a0a05 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5027,6 +5027,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 a5471f9fc..91018b590 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -302,6 +302,7 @@ TESTS = \
objects/interface-property-base-impl.vala \
objects/interface-property-delegate.vala \
objects/interface-property-override.vala \
+ objects/member-initializer-base-properties.vala \
objects/methods.vala \
objects/paramspec.vala \
objects/properties.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]