[vala] codegen: Custom abstract methods of GLib.Source are handled differently



commit 930ed6e6808a2e5bbe6acee7e6903cecd24c82ac
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Jun 16 10:36:10 2018 +0200

    codegen: Custom abstract methods of GLib.Source are handled differently
    
    Regression of 28b4f45b709622e821e86655f245fdcb75d3afaf
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/641

 codegen/valagtypemodule.vala |  6 ++++--
 tests/Makefile.am            |  1 +
 tests/objects/gsource.vala   | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 3d977784d..500d506bc 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1617,6 +1617,8 @@ public class Vala.GTypeModule : GErrorModule {
 
                push_function (func);
 
+               bool is_gsource = cl.base_class == gsource_type;
+
                if (cl.is_compact) {
                        // Add declaration, since the instance_init function is explicitly called
                        // by the creation methods
@@ -1624,7 +1626,7 @@ public class Vala.GTypeModule : GErrorModule {
 
                        // connect overridden methods
                        foreach (Method m in cl.get_methods ()) {
-                               if (m.base_method == null) {
+                               if (m.base_method == null || is_gsource) {
                                        continue;
                                }
                                var base_type = (ObjectTypeSymbol) m.base_method.parent_symbol;
@@ -1646,7 +1648,7 @@ public class Vala.GTypeModule : GErrorModule {
 
                        // connect overridden properties
                        foreach (Property prop in cl.get_properties ()) {
-                               if (prop.base_property == null) {
+                               if (prop.base_property == null || is_gsource) {
                                        continue;
                                }
                                var base_type = prop.base_property.parent_symbol;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 612f9cc31..c202f3015 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -234,6 +234,7 @@ TESTS = \
        objects/generics.vala \
        objects/initially-unowned.vala \
        objects/fields.vala \
+       objects/gsource.vala \
        objects/interfaces.vala \
        objects/methods.vala \
        objects/paramspec.vala \
diff --git a/tests/objects/gsource.vala b/tests/objects/gsource.vala
new file mode 100644
index 000000000..8ee450f1f
--- /dev/null
+++ b/tests/objects/gsource.vala
@@ -0,0 +1,18 @@
+class FooSource : Source {
+       public override bool prepare (out int timeout) {
+               timeout = 1000;
+               return false;
+       }
+
+       public override bool check () {
+               return false;
+       }
+
+       public override bool dispatch (SourceFunc callback) {
+               return false;
+       }
+}
+
+void main () {
+       var foo = new FooSource ();
+}


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