]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use equal method of base-struct for derived structs
authorRico Tzschichholz <ricotz@t-online.de>
Mon, 17 Dec 2012 20:27:27 +0000 (21:27 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 18 Jan 2013 18:23:12 +0000 (19:23 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=690380

codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/structs/bug690380.vala [new file with mode: 0644]

index f84ed670ff5d3494de5019fbbb6ee081b179c005..93d04eeecb60865f1022e4c83abdaa54c4de8809 100644 (file)
@@ -2686,6 +2686,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        return equal_func;
                }
 
+               if (st.base_struct != null) {
+                       return generate_struct_equal_function (st.base_struct);
+               }
+
                var function = new CCodeFunction (equal_func, "gboolean");
                function.modifiers = CCodeModifiers.STATIC;
 
index 93dc65dbfdc3821cf47153a3363f490ef6e21668..eedf8ced0358c48d427de9187360bc2c88e1cac0 100644 (file)
@@ -88,6 +88,7 @@ TESTS = \
        structs/bug667890.vala \
        structs/bug669580.vala \
        structs/bug685177.vala \
+       structs/bug690380.vala \
        delegates/delegates.vala \
        delegates/bug539166.vala \
        delegates/bug595610.vala \
diff --git a/tests/structs/bug690380.vala b/tests/structs/bug690380.vala
new file mode 100644 (file)
index 0000000..38fcc83
--- /dev/null
@@ -0,0 +1,18 @@
+struct Foo {
+       int i;
+}
+
+struct Bar : Foo {
+}
+
+void main () {
+       var f1 = Foo () { i = 42 };
+       var f2 = Foo () { i = 42 };
+
+       assert (f1 == f2);
+
+       var b1 = Bar () { i = 42 };
+       var b2 = Bar () { i = 42 };
+
+       assert (b1 == b2);
+}