[vala] codegen: Do not initialize temp variable when getting delegate property



commit d78b4e8c2c065fa0be89e0939c3ca7f1ab2e28b2
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat May 28 09:30:52 2011 +0200

    codegen: Do not initialize temp variable when getting delegate property
    
    Fixes bug 641182.

 codegen/valaccodememberaccessmodule.vala |    2 +-
 tests/Makefile.am                        |    1 +
 tests/asynchronous/bug641182.vala        |   16 ++++++++++++++++
 3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 8dd8b2f..6f2478b 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -268,7 +268,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					} else {
 						delegate_type = base_property.property_type as DelegateType;
 						if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
-							temp_var = get_temp_variable (new PointerType (new VoidType ()));
+							temp_var = get_temp_variable (new PointerType (new VoidType ()), false, expr, false);
 							ctemp = get_variable_cexpression (temp_var.name);
 							emit_temp_var (temp_var);
 							ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b02a449..91b8c75 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -104,6 +104,7 @@ TESTS = \
 	asynchronous/bug613484.vala \
 	asynchronous/bug620740.vala \
 	asynchronous/bug639591.vala \
+	asynchronous/bug641182.vala \
 	asynchronous/bug646945.vala \
 	asynchronous/closures.vala \
 	dbus/basic-types.test \
diff --git a/tests/asynchronous/bug641182.vala b/tests/asynchronous/bug641182.vala
new file mode 100644
index 0000000..af7e396
--- /dev/null
+++ b/tests/asynchronous/bug641182.vala
@@ -0,0 +1,16 @@
+public delegate void Bar ();
+
+class Foo {
+        public Bar bar { get; set; }
+}
+
+async void test () {
+        var foo = new Foo ();
+        var i = 0;
+        foo.bar = () => { i++; };
+        foo.bar ();
+}
+
+void main() {
+        test ();
+}



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