]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support constructor chain up to GObject using Object (...)
authorJürg Billeter <j@bitron.ch>
Wed, 21 Oct 2009 19:28:28 +0000 (21:28 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 21 Oct 2009 19:28:28 +0000 (21:28 +0200)
vala/valamethodcall.vala

index aedeb96a4392095ee78c1a6b8593a40f7d762bff..ab4702432cca1612c4bda27d8f03733a78099fe3 100644 (file)
@@ -141,7 +141,7 @@ public class Vala.MethodCall : Expression {
 
                var mtype = call.value_type;
 
-               if (mtype is ObjectType) {
+               if (mtype is ObjectType || (analyzer.context.profile == Profile.GOBJECT && call.symbol_reference == analyzer.object_type)) {
                        // constructor chain-up
                        var cm = analyzer.find_current_method () as CreationMethod;
                        if (cm == null) {
@@ -155,17 +155,29 @@ public class Vala.MethodCall : Expression {
                        }
                        cm.chain_up = true;
 
-                       var otype = (ObjectType) mtype;
-                       var cl = (Class) otype.type_symbol;
-                       var base_cm = cl.default_construction_method;
-                       if (base_cm == null) {
-                               error = true;
-                               Report.error (source_reference, "chain up to `%s' not supported".printf (cl.get_full_name ()));
-                               return false;
-                       } else if (!base_cm.has_construct_function) {
-                               error = true;
-                               Report.error (source_reference, "chain up to `%s' not supported".printf (base_cm.get_full_name ()));
-                               return false;
+                       if (mtype is ObjectType) {
+                               var otype = (ObjectType) mtype;
+                               var cl = (Class) otype.type_symbol;
+                               var base_cm = cl.default_construction_method;
+                               if (base_cm == null) {
+                                       error = true;
+                                       Report.error (source_reference, "chain up to `%s' not supported".printf (cl.get_full_name ()));
+                                       return false;
+                               } else if (!base_cm.has_construct_function) {
+                                       error = true;
+                                       Report.error (source_reference, "chain up to `%s' not supported".printf (base_cm.get_full_name ()));
+                                       return false;
+                               }
+                       } else {
+                               // GObject chain up
+                               var cl = cm.parent_symbol as Class;
+                               if (cl == null || !cl.is_subtype_of (analyzer.object_type)) {
+                                       error = true;
+                                       Report.error (source_reference, "chain up to `GLib.Object' not supported");
+                                       return false;
+                               }
+                               call.value_type = new ObjectType (analyzer.object_type);
+                               mtype = call.value_type;
                        }
                }