]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Move nullable setting of LocalVariable with reference type to check() b9f8e20c75fb2f023f3b54979e1d25cac13071a9
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 16 Oct 2018 20:19:24 +0000 (22:19 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 17 Oct 2018 13:41:50 +0000 (15:41 +0200)
... and keep skipping it in non-null mode.

Originally introduced with 80c18a1d1ff357be7f1d0f50f1aa331f206a0a0a

Fixes https://gitlab.gnome.org/GNOME/vala/issues/684

vala/valalocalvariable.vala
vala/valasymbolresolver.vala

index 9391bdc5484c7028e4ec66231a34dfecfd74ffe3..591edb8fb78164f9429258962c02122b9c04cdb8 100644 (file)
@@ -79,6 +79,19 @@ public class Vala.LocalVariable : Variable {
 
                checked = true;
 
+               if (!context.experimental_non_null) {
+                       // local reference variables are considered nullable
+                       // except when using experimental non-null enhancements
+                       if (variable_type is ReferenceType) {
+                               var array_type = variable_type as ArrayType;
+                               if (array_type != null && array_type.fixed_length) {
+                                       // local fixed length arrays are not nullable
+                               } else {
+                                       variable_type.nullable = true;
+                               }
+                       }
+               }
+
                if (variable_type != null) {
                        if (variable_type is VoidType) {
                                error = true;
index 55fa94f629ed44a1640a1c9671404e72f17d4db2..0913dedf28ca29b2fe61796162fb70d3a8bbce2e 100644 (file)
@@ -28,7 +28,6 @@ using GLib;
  * Code visitor resolving symbol names.
  */
 public class Vala.SymbolResolver : CodeVisitor {
-       CodeContext context;
        Symbol root_symbol;
        Scope current_scope;
 
@@ -38,13 +37,11 @@ public class Vala.SymbolResolver : CodeVisitor {
         * @param context a code context
         */
        public void resolve (CodeContext context) {
-               this.context = context;
                root_symbol = context.root;
 
                context.root.accept (this);
 
                root_symbol = null;
-               this.context = null;
        }
 
        public override void visit_namespace (Namespace ns) {
@@ -385,18 +382,6 @@ public class Vala.SymbolResolver : CodeVisitor {
 
        public override void visit_local_variable (LocalVariable local) {
                local.accept_children (this);
-               if (!context.experimental_non_null) {
-                       // local reference variables are considered nullable
-                       // except when using experimental non-null enhancements
-                       if (local.variable_type is ReferenceType) {
-                               var array_type = local.variable_type as ArrayType;
-                               if (array_type != null && array_type.fixed_length) {
-                                       // local fixed length arrays are not nullable
-                               } else {
-                                       local.variable_type.nullable = true;
-                               }
-                       }
-               }
        }
 
        public override void visit_initializer_list (InitializerList list) {