summaryrefslogtreecommitdiff
path: root/vala/valamemberaccess.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2010-03-21 16:14:58 +0100
committerJürg Billeter <j@bitron.ch>2010-03-21 16:19:35 +0100
commit7082c10201cd471e85f80a07ab161ea20442f33d (patch)
tree15df14b0915d6b313068673c2536b4f6de68615a /vala/valamemberaccess.vala
parent2a02ef9dbaaf496990d3e1f8747e91642ad6d5ee (diff)
downloadvala-7082c10201cd471e85f80a07ab161ea20442f33d.tar.gz
Fix closures in property accessors
Fixes bug 613483.
Diffstat (limited to 'vala/valamemberaccess.vala')
-rw-r--r--vala/valamemberaccess.vala25
1 files changed, 21 insertions, 4 deletions
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 63127c24f..981981ef7 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -446,10 +446,10 @@ public class Vala.MemberAccess : Expression {
if (member is LocalVariable) {
var local = (LocalVariable) member;
var block = local.parent_symbol as Block;
- if (block != null && analyzer.find_parent_method (block) != analyzer.current_method) {
+ if (block != null && analyzer.find_parent_method_or_property_accessor (block) != analyzer.current_method_or_property_accessor) {
// mark all methods between current method and the captured
// block as closures (to support nested closures)
- Symbol sym = analyzer.current_method;
+ Symbol sym = analyzer.current_method_or_property_accessor;
while (sym != block) {
var method = sym as Method;
if (method != null) {
@@ -467,10 +467,10 @@ public class Vala.MemberAccess : Expression {
} else if (member is FormalParameter) {
var param = (FormalParameter) member;
var m = param.parent_symbol as Method;
- if (m != null && m != analyzer.current_method && param != m.this_parameter) {
+ if (m != null && m != analyzer.current_method_or_property_accessor && param != m.this_parameter) {
// mark all methods between current method and the captured
// parameter as closures (to support nested closures)
- Symbol sym = analyzer.current_method;
+ Symbol sym = analyzer.current_method_or_property_accessor;
while (sym != m) {
var method = sym as Method;
if (method != null) {
@@ -486,6 +486,23 @@ public class Vala.MemberAccess : Expression {
error = true;
Report.error (source_reference, "Cannot capture reference or output parameter `%s'".printf (param.get_full_name ()));
}
+ } else {
+ var acc = param.parent_symbol.parent_symbol as PropertyAccessor;
+ if (acc != null && acc != analyzer.current_method_or_property_accessor && param != acc.prop.this_parameter) {
+ // mark all methods between current method and the captured
+ // parameter as closures (to support nested closures)
+ Symbol sym = analyzer.current_method_or_property_accessor;
+ while (sym != m) {
+ var method = sym as Method;
+ if (method != null) {
+ method.closure = true;
+ }
+ sym = sym.parent_symbol;
+ }
+
+ param.captured = true;
+ acc.body.captured = true;
+ }
}
} else if (member is Field) {
var f = (Field) member;