[vala/0.34] vala: Fix MemberAccess.is_non_null() for EnumValue constants



commit 4857174a786633fcc85fe75ca096e512fe738201
Author: Ole André Vadla Ravnås <oleavr gmail com>
Date:   Tue Mar 14 20:44:45 2017 +0100

    vala: Fix MemberAccess.is_non_null() for EnumValue constants
    
    This is because an EnumValue object does not have a type reference.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780050

 tests/Makefile.am          |    1 +
 tests/enums/bug780050.vala |   10 ++++++++++
 vala/valamemberaccess.vala |    2 +-
 3 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a58235b..620e6ec 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -91,6 +91,7 @@ TESTS = \
        enums/flags.vala \
        enums/bug673879.vala \
        enums/bug763831.vala \
+       enums/bug780050.vala \
        structs/structs.vala \
        structs/gvalue.vala \
        structs/bug530605.vala \
diff --git a/tests/enums/bug780050.vala b/tests/enums/bug780050.vala
new file mode 100644
index 0000000..b69f7c0
--- /dev/null
+++ b/tests/enums/bug780050.vala
@@ -0,0 +1,10 @@
+enum Bar {
+       FOO
+}
+
+namespace Foo {
+       Bar bar = Bar.FOO;
+}
+
+void main () {
+}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 6be9fcd..a22dff3 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -183,7 +183,7 @@ public class Vala.MemberAccess : Expression {
        public override bool is_non_null () {
                var c = symbol_reference as Constant;
                if (c != null) {
-                       return !c.type_reference.nullable;
+                       return (c is EnumValue || !c.type_reference.nullable);
                } else {
                        return false;
                }


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