[vala/staging] codegen: Fix chain-up regression with real non-null struct parameters
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Fix chain-up regression with real non-null struct parameters
- Date: Wed, 20 Dec 2017 20:44:45 +0000 (UTC)
commit 60563fc8e5e795ec70512fcf386e058d2912e7c2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Dec 20 21:34:20 2017 +0100
codegen: Fix chain-up regression with real non-null struct parameters
Regression of b9035aaf17a9a97a070812a8ee83251fd3893b1e
https://bugzilla.gnome.org/show_bug.cgi?id=791785
codegen/valaccodememberaccessmodule.vala | 10 ++++++++--
tests/Makefile.am | 1 +
tests/chainup/bug791785.vala | 23 +++++++++++++++++++++++
3 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index f313f55..13d9d4a 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -742,8 +742,14 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
// special handling for types such as va_list
use_temp = false;
}
- if (variable is Parameter && (variable.name == "this" || ((Parameter) variable).direction !=
ParameterDirection.OUT)) {
- use_temp = false;
+ if (variable is Parameter) {
+ var param = (Parameter) variable;
+ if (variable.name == "this") {
+ use_temp = false;
+ } else if ((param.direction != ParameterDirection.OUT)
+ && !(param.variable_type.is_real_non_null_struct_type ())) {
+ use_temp = false;
+ }
}
if (variable.single_assignment && !result.value_type.is_real_non_null_struct_type ()) {
// no need to copy values from variables that are assigned exactly once
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eb00912..10a62d5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -59,6 +59,7 @@ TESTS = \
chainup/struct-base-foo.vala \
chainup/struct-this.vala \
chainup/struct-this-foo.vala \
+ chainup/bug791785.vala \
pointers/bug590641.vala \
namespaces.vala \
methods/lambda.vala \
diff --git a/tests/chainup/bug791785.vala b/tests/chainup/bug791785.vala
new file mode 100644
index 0000000..eb46b01
--- /dev/null
+++ b/tests/chainup/bug791785.vala
@@ -0,0 +1,23 @@
+struct Foo {
+ public int i;
+}
+
+abstract class AbstractBar {
+ public Foo foo;
+
+ public AbstractBar (Foo foo) {
+ this.foo = foo;
+ }
+}
+
+class Bar : AbstractBar {
+ public Bar (Foo foo) {
+ base (foo);
+ }
+}
+
+void main () {
+ var bar = new Bar ({ 42 });
+ assert (bar.foo.i == 42);
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]