[vala/staging] vala: Don't replace assignments for local variables with non-null simple-types
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Don't replace assignments for local variables with non-null simple-types
- Date: Thu, 22 Nov 2018 14:15:08 +0000 (UTC)
commit e701142da4601ece5ca71cc4484728b08969c74e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 22 12:40:23 2018 +0100
vala: Don't replace assignments for local variables with non-null simple-types
vala/valaassignment.vala | 10 ++++------
vala/valadatatype.vala | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 81a7139ba..a6bb74f96 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -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;
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 1e2f2c4cf..09209a7fd 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]