[vala/wip/transform: 58/63] codegen: Fix making local variables and constants active



commit ca865cfb518b56367d0acbff750d2f2b7a4e1914
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Oct 27 01:20:09 2012 +0200

    codegen: Fix making local variables and constants active

 codegen/valaccodetransformer.vala   |    9 ++-------
 tests/methods/symbolresolution.vala |    8 ++++++++
 2 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index 2ba14a0..8616653 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -61,6 +61,7 @@ public class Vala.CCodeTransformer : CodeTransformer {
 	}
 
 	public override void visit_constant (Constant c) {
+		c.active = true;
 		c.accept_children (this);
 	}
 
@@ -101,13 +102,6 @@ public class Vala.CCodeTransformer : CodeTransformer {
 	}
 
 	public override void visit_block (Block b) {
-		foreach (LocalVariable local in b.get_local_variables ()) {
-			local.active = true;
-		}
-		foreach (Constant constant in b.get_local_constants ()) {
-			constant.active = true;
-		}
-
 		b.accept_children (this);
 
 		foreach (LocalVariable local in b.get_local_variables ()) {
@@ -123,6 +117,7 @@ public class Vala.CCodeTransformer : CodeTransformer {
 	}
 
 	public override void visit_local_variable (LocalVariable local) {
+		local.active = true;
 		local.accept_children (this);
 	}
 
diff --git a/tests/methods/symbolresolution.vala b/tests/methods/symbolresolution.vala
index 90fe97c..ba3beec 100644
--- a/tests/methods/symbolresolution.vala
+++ b/tests/methods/symbolresolution.vala
@@ -9,6 +9,14 @@ public class Class {
 		Foo func = () => { foo (); };
 		func ();
 	}
+
+
+	void active_scope () {
+		foreach (var bar in new string[] {}) {
+		}
+
+		var bar = "bar";
+	}
 }
 
 void main () {



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