summaryrefslogtreecommitdiff
path: root/vala/valaforeachstatement.vala
diff options
context:
space:
mode:
Diffstat (limited to 'vala/valaforeachstatement.vala')
-rw-r--r--vala/valaforeachstatement.vala10
1 files changed, 2 insertions, 8 deletions
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index 67063bbe1..ada291ccd 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -154,6 +154,8 @@ public class Vala.ForeachStatement : Block {
checked = true;
+ owner = context.analyzer.get_current_symbol (parent_node).scope;
+
// analyze collection expression first, used for type inference
if (!collection.check (context)) {
// ignore inner error
@@ -353,16 +355,10 @@ public class Vala.ForeachStatement : Block {
element_variable = new LocalVariable (type_reference, variable_name, null, source_reference);
- body.scope.add (variable_name, element_variable);
-
body.add_local_variable (element_variable);
element_variable.active = true;
element_variable.checked = true;
- // analyze body
- owner = context.analyzer.current_symbol.scope;
- context.analyzer.current_symbol = this;
-
// call add_local_variable to check for shadowed variable
add_local_variable (element_variable);
remove_local_variable (element_variable);
@@ -373,8 +369,6 @@ public class Vala.ForeachStatement : Block {
local.active = false;
}
- context.analyzer.current_symbol = context.analyzer.current_symbol.parent_symbol;
-
collection_variable = new LocalVariable (collection_type.copy (), "%s_collection".printf (variable_name));
add_local_variable (collection_variable);