[vala/0.40] vala: Copy CCode instance_pos argument from virtual/abstract base methods



commit 706e9b0954a8aa14f7637a7330c8227a8e4e7c98
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Nov 8 12:48:20 2018 +0100

    vala: Copy CCode instance_pos argument from virtual/abstract base methods
    
    https://bugzilla.gnome.org/show_bug.cgi?id=540483

 tests/Makefile.am            |  1 +
 tests/methods/bug540483.vala | 38 ++++++++++++++++++++++++++++++++++++++
 vala/valamethod.vala         |  2 ++
 3 files changed, 41 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7712231a3..124593bd5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -82,6 +82,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
index 000000000..1b12f91a9
--- /dev/null
+++ b/tests/methods/bug540483.vala
@@ -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);
+}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index a2bd57c45..4269c5f4f 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -566,6 +566,7 @@ public class Vala.Method : Subroutine, Callable {
                                }
 
                                _base_method = base_method;
+                               copy_attribute_double (base_method, "CCode", "instance_pos");
                                return;
                        }
                }
@@ -613,6 +614,7 @@ public class Vala.Method : Subroutine, Callable {
                                                }
                                                
                                                _base_interface_method = base_method;
+                                               copy_attribute_double (base_method, "CCode", "instance_pos");
                                                return;
                                        }
                                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]