]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Copy CCode instance_pos argument from virtual/abstract base methods
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Nov 2018 11:48:20 +0000 (12:48 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Nov 2018 12:04:12 +0000 (13:04 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=540483

tests/Makefile.am
tests/methods/bug540483.vala [new file with mode: 0644]
vala/valamethod.vala

index 7b0628ca9979ccf9a65f4baa7074489e911dfc28..b84d952a6f5528ae19d9142fb409b497e65fbfe4 100644 (file)
@@ -88,6 +88,7 @@ TESTS = \
        methods/prepostconditions.vala \
        methods/same-name.vala \
        methods/symbolresolution.vala \
+       methods/bug540483.vala \
        methods/bug595538.vala \
        methods/bug596726.vala \
        methods/bug597426.vala \
diff --git a/tests/methods/bug540483.vala b/tests/methods/bug540483.vala
new file mode 100644 (file)
index 0000000..1b12f91
--- /dev/null
@@ -0,0 +1,38 @@
+interface IFoo {
+       [CCode (instance_pos = -1)]
+       public abstract void foo (int i);
+}
+
+class Foo : IFoo {
+       public virtual void foo (int i) {
+               assert (i == 23);
+       }
+}
+
+class Bar : Foo {
+       public override void foo (int i) {
+               assert (i == 42);
+       }
+}
+
+abstract class Baz {
+       [CCode (instance_pos = -1)]
+       public abstract void foo (int i);
+}
+
+class Manam : Baz {
+       public override void foo (int i) {
+               assert (i == 4711);
+       }
+}
+
+void main () {
+       var foo = new Foo ();
+       foo.foo (23);
+
+       var bar = new Bar ();
+       bar.foo (42);
+
+       var manam = new Manam ();
+       manam.foo (4711);
+}
index f567b246edb0be3bd4b17a6795dc837c46881541..955de7e000e271c968b9836e254dd8dccf1f3786 100644 (file)
@@ -601,6 +601,7 @@ public class Vala.Method : Subroutine, Callable {
                                }
 
                                _base_method = base_method;
+                               copy_attribute_double (base_method, "CCode", "instance_pos");
                                return;
                        }
                }
@@ -648,6 +649,7 @@ public class Vala.Method : Subroutine, Callable {
                                                }
 
                                                _base_interface_method = base_method;
+                                               copy_attribute_double (base_method, "CCode", "instance_pos");
                                                return;
                                        }
                                }