[vala/0.14] codegen: Fix type check for vfunc returning SimpleType structs
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.14] codegen: Fix type check for vfunc returning SimpleType structs
- Date: Tue, 31 Jan 2012 13:15:32 +0000 (UTC)
commit 393f45975722ceee5b22698b04df3148511d7845
Author: Luca Bruno <lucabru src gnome org>
Date: Fri Jan 13 21:52:56 2012 +0100
codegen: Fix type check for vfunc returning SimpleType structs
Fixes bug 667890.
codegen/valaccodemethodmodule.vala | 7 +++++++
tests/Makefile.am | 1 +
tests/structs/bug667890.vala | 10 ++++++++++
3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index a5be334..8ef6e66 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -912,6 +912,13 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
push_function (vfunc);
+ if (context.assert && m.return_type.data_type is Struct && ((Struct) m.return_type.data_type).is_simple_type () && default_value_for_type (m.return_type, false) == null) {
+ // the type check will use the result variable
+ var vardecl = new CCodeVariableDeclarator ("result", default_value_for_type (m.return_type, true));
+ vardecl.init0 = true;
+ ccode.add_declaration (get_ccode_name (m.return_type), vardecl);
+ }
+
// add a typecheck statement for "self"
create_method_type_check_statement (m, return_type, (TypeSymbol) m.parent_symbol, true, "self");
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d4e1af1..8835bff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@ TESTS = \
structs/bug658048.vala \
structs/bug660426.vala \
structs/bug661945.vala \
+ structs/bug667890.vala \
delegates/delegates.vala \
delegates/bug539166.vala \
delegates/bug595610.vala \
diff --git a/tests/structs/bug667890.vala b/tests/structs/bug667890.vala
new file mode 100644
index 0000000..768ab8c
--- /dev/null
+++ b/tests/structs/bug667890.vala
@@ -0,0 +1,10 @@
+[SimpleType]
+struct Foo {
+ public int foo;
+}
+
+interface Bar : Object {
+ public abstract Foo bar ();
+}
+
+void main () { }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]