]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix creation of lambdas inside interface methods
authorMaciej Piechotka <uzytkownik2@gmail.com>
Sun, 24 Apr 2011 20:01:31 +0000 (22:01 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Wed, 27 Apr 2011 19:28:36 +0000 (21:28 +0200)
Fixes bug 648320.

codegen/valaccodebasemodule.vala
codegen/valaccodemethodmodule.vala
tests/Makefile.am
tests/methods/bug648320.vala [new file with mode: 0644]

index 2b4be0e499231df542aa1674f2b82010c50e86ac..8e1ca6df68398cac47734255675906c295108de5 100644 (file)
@@ -1703,7 +1703,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        } else {
                                if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE) ||
                                           (current_property_accessor != null && current_property_accessor.prop.binding == MemberBinding.INSTANCE)) {
-                                       data.add_field ("%s *".printf (current_class.get_cname ()), "self");
+                                       data.add_field ("%s *".printf (current_type_symbol.get_cname ()), "self");
                                }
 
                                if (current_method != null) {
@@ -1767,7 +1767,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE &&
                                                              (!(current_method is CreationMethod) || current_method.body != b)) ||
                                           (current_property_accessor != null && current_property_accessor.prop.binding == MemberBinding.INSTANCE)) {
-                                       var ref_call = new CCodeFunctionCall (get_dup_func_expression (new ObjectType (current_class), b.source_reference));
+                                       var ref_call = new CCodeFunctionCall (get_dup_func_expression (get_data_type_for_symbol (current_type_symbol), b.source_reference));
                                        ref_call.add_argument (get_result_cexpression ("self"));
 
                                        ccode.add_assignment (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (block_id)), "self"), ref_call);
@@ -1854,7 +1854,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        } else {
                                if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE) ||
                                           (current_property_accessor != null && current_property_accessor.prop.binding == MemberBinding.INSTANCE)) {
-                                       var this_value = new GLibValue (new ObjectType (current_class), new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data%d_".printf (block_id)), "self"));
+                                       var this_value = new GLibValue (get_data_type_for_symbol (current_type_symbol), new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data%d_".printf (block_id)), "self"));
                                        ccode.add_expression (destroy_value (this_value));
                                }
                        }
index 96355a72452318ced2a3eb5a5dd4bc901be8e948..f082fca60bf37751ce3e76152c19b28b9aa137ef 100644 (file)
@@ -403,7 +403,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                        // as closures have block data parameter
                                        if (m.binding == MemberBinding.INSTANCE) {
                                                var cself = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data%d_".printf (block_id)), "self");
-                                               ccode.add_declaration ("%s *".printf (current_class.get_cname ()), new CCodeVariableDeclarator ("self"));
+                                               ccode.add_declaration ("%s *".printf (current_type_symbol.get_cname ()), new CCodeVariableDeclarator ("self"));
                                                ccode.add_assignment (new CCodeIdentifier ("self"), cself);
                                        }
 
index d5f979d51b4164160a60f4d36df4dfd140b39720..1cb60fc67632b27e30d881a2aaa7004f7ded3fe0 100644 (file)
@@ -36,6 +36,7 @@ TESTS = \
        methods/bug613483.vala \
        methods/bug620673.vala \
        methods/bug646345.vala \
+       methods/bug648320.vala \
        control-flow/break.vala \
        control-flow/expressions-conditional.vala \
        control-flow/for.vala \
diff --git a/tests/methods/bug648320.vala b/tests/methods/bug648320.vala
new file mode 100644 (file)
index 0000000..e94c14e
--- /dev/null
@@ -0,0 +1,11 @@
+public interface Foo : Object {
+       public abstract int i { get; set; }
+
+       public void foo () {
+               int j = 0;
+               SourceFunc bar = () => j == i;
+       }
+}
+
+void main() {
+}