summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--codegen/valaccodemethodmodule.vala2
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/chainup/class-compact-this.vala29
3 files changed, 31 insertions, 1 deletions
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 8e1e25db1..944d6a00a 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -641,7 +641,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
ccode.add_assignment (get_this_cexpression (), ccall);
}
- if (cl.base_class == null) {
+ if (cl.base_class == null && !(((CreationMethod) m).chain_up && cl.is_compact)) {
var cinitcall = new CCodeFunctionCall (new CCodeIdentifier ("%s_instance_init".printf (get_ccode_lower_case_name (cl, null))));
cinitcall.add_argument (get_this_cexpression ());
if (!cl.is_compact) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3454623d2..a802bc8fb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -143,6 +143,7 @@ TESTS = \
chainup/class-base.vala \
chainup/class-base-foo.vala \
chainup/class-compact-base.vala \
+ chainup/class-compact-this.vala \
chainup/class-object.vala \
chainup/class-this.vala \
chainup/class-this-foo.vala \
diff --git a/tests/chainup/class-compact-this.vala b/tests/chainup/class-compact-this.vala
new file mode 100644
index 000000000..aed1ab3fe
--- /dev/null
+++ b/tests/chainup/class-compact-this.vala
@@ -0,0 +1,29 @@
+[Compact]
+class Foo {
+ public int i = 42;
+ public int j = 23;
+
+ public Foo () {
+ assert (i == 42);
+ j = 23;
+ }
+
+ public Foo.bar () {
+ this ();
+ assert (i == 42);
+ assert (j == 23);
+ }
+}
+
+void main () {
+ {
+ var foo = new Foo ();
+ assert (foo.i == 42);
+ assert (foo.j == 23);
+ }
+ {
+ var foo = new Foo.bar ();
+ assert (foo.i == 42);
+ assert (foo.j == 23);
+ }
+}