]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Don't replace assignments for local variables with non-null simple-types e701142da4601ece5ca71cc4484728b08969c74e
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 22 Nov 2018 11:40:23 +0000 (12:40 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 22 Nov 2018 14:06:55 +0000 (15:06 +0100)
vala/valaassignment.vala
vala/valadatatype.vala

index 81a7139ba7b5067ed9d849cfaf213837f0c034fa..a6bb74f960458bac760279abdaba96792621f27a 100644 (file)
@@ -220,13 +220,13 @@ public class Vala.Assignment : Expression {
                        return false;
                }
 
-               if (operator != AssignmentOperator.SIMPLE && left is MemberAccess) {
+               unowned MemberAccess? ma = left as MemberAccess;
+               if (operator != AssignmentOperator.SIMPLE && ma != null
+                   && !(left.value_type.is_non_null_simple_type () && ma.symbol_reference is LocalVariable)) {
                        // transform into simple assignment
                        // FIXME: only do this if the backend doesn't support
                        // the assignment natively
 
-                       var ma = (MemberAccess) left;
-
                        var old_value = new MemberAccess (ma.inner, ma.member_name);
 
                        BinaryOperator bop;
@@ -256,9 +256,7 @@ public class Vala.Assignment : Expression {
                        operator = AssignmentOperator.SIMPLE;
                }
 
-               if (left is MemberAccess) {
-                       var ma = (MemberAccess) left;
-
+               if (ma != null) {
                        if (ma.symbol_reference is Property) {
                                var prop = (Property) ma.symbol_reference;
 
index 1e2f2c4cfc0a65b4eaa5ff367e9eeb1936339ac3..09209a7fd8a42ba46c85611b5f22570ee77f97ec 100644 (file)
@@ -432,7 +432,7 @@ public abstract class Vala.DataType : CodeNode {
                return is_real_struct_type () && !nullable;
        }
 
-       bool is_non_null_simple_type () {
+       public bool is_non_null_simple_type () {
                unowned Struct s = data_type as Struct;
                if (s != null && s.is_simple_type ()) {
                        return !nullable;