[vala/0.48] vala: Fix ownership inheritance of "unowned var" in foreach statement



commit 86b6b711822ebb1dd81d6fa346376e222aa31443
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Mar 6 09:46:32 2021 +0100

    vala: Fix ownership inheritance of "unowned var" in foreach statement

 vala/valaforeachstatement.vala | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index a04076b58..e225047bc 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -332,9 +332,10 @@ public class Vala.ForeachStatement : Block {
                // analyze element type
                if (type_reference is VarType) {
                        // var type
+                       bool value_owned = type_reference.value_owned;
                        type_reference = element_type.copy ();
                        // FIXME Only follows "unowned var" otherwise inherit ownership of element-type
-                       if (!type_reference.value_owned) {
+                       if (!value_owned) {
                                type_reference.value_owned = false;
                        }
                } else if (!element_type.compatible (type_reference)) {
@@ -354,9 +355,10 @@ public class Vala.ForeachStatement : Block {
                // analyze element type
                if (type_reference is VarType) {
                        // var type
+                       bool value_owned = type_reference.value_owned;
                        type_reference = element_type.copy ();
                        // FIXME Only follows "unowned var" otherwise inherit ownership of element-type
-                       if (!type_reference.value_owned) {
+                       if (!value_owned) {
                                type_reference.value_owned = false;
                        }
                } else if (!element_type.compatible (type_reference)) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]