From: Rico Tzschichholz Date: Mon, 17 Dec 2012 20:27:27 +0000 (+0100) Subject: codegen: Use equal method of base-struct for derived structs X-Git-Tag: 0.19.0~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a18c17e614ad5d3e8b6af31e1b986f717af30cbb;p=thirdparty%2Fvala.git codegen: Use equal method of base-struct for derived structs https://bugzilla.gnome.org/show_bug.cgi?id=690380 --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index f84ed670f..93d04eeec 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -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; diff --git a/tests/Makefile.am b/tests/Makefile.am index 93dc65dbf..eedf8ced0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..38fcc834f --- /dev/null +++ b/tests/structs/bug690380.vala @@ -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); +}