[vala] codegen: Fix lambda expressions in instance destructor
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix lambda expressions in instance destructor
- Date: Sat, 10 Sep 2011 14:35:19 +0000 (UTC)
commit 6faa435137cc7006c2ba2a0c946646a2a17a3d02
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Sep 10 11:05:59 2011 +0200
codegen: Fix lambda expressions in instance destructor
Fixes bug 646362.
codegen/valaccodebasemodule.vala | 12 ++++++++++++
tests/Makefile.am | 1 +
tests/objects/bug646362.vala | 9 +++++++++
3 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 17e1abe..a21c4d4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -126,6 +126,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
}
+ public Destructor? current_destructor {
+ get {
+ var sym = current_symbol;
+ while (sym is Block) {
+ sym = sym.parent_symbol;
+ }
+ return sym as Destructor;
+ }
+ }
+
public DataType? current_return_type {
get {
var m = current_method;
@@ -5903,6 +5913,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return current_property_accessor.prop.this_parameter.variable_type;
} else if (current_constructor != null && current_constructor.binding == MemberBinding.INSTANCE) {
return current_constructor.this_parameter.variable_type;
+ } else if (current_destructor != null && current_destructor.binding == MemberBinding.INSTANCE) {
+ return current_destructor.this_parameter.variable_type;
}
return null;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 751766d..5c8ddd3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -107,6 +107,7 @@ TESTS = \
objects/bug634782.vala \
objects/bug642809.vala \
objects/bug643711.vala \
+ objects/bug646362.vala \
objects/bug646792.vala \
objects/bug653138.vala \
objects/bug654702.vala \
diff --git a/tests/objects/bug646362.vala b/tests/objects/bug646362.vala
new file mode 100644
index 0000000..526db6c
--- /dev/null
+++ b/tests/objects/bug646362.vala
@@ -0,0 +1,9 @@
+public class Foo : Object {
+ int bar;
+ ~Foo() {
+ var baz = bar;
+ SourceFunc f = () => baz == 2;
+ }
+}
+
+void main () { }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]