[vala/staging] vala: Move nullable setting of LocalVariable with reference type to check()



commit dbdd21f730cc5ea5b550545aca6c73a89a6bf513
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Oct 16 22:19:24 2018 +0200

    vala: Move nullable setting of LocalVariable with reference type to check()
    
    ... and keep skipping it in non-null mode.
    
    Originally introduced with 80c18a1d1ff357be7f1d0f50f1aa331f206a0a0a
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/684

 vala/valalocalvariable.vala  | 13 +++++++++++++
 vala/valasymbolresolver.vala | 15 ---------------
 2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index 9391bdc54..591edb8fb 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -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;
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index 55fa94f62..0913dedf2 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -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) {


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