]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Improve instance method detection
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 30 Jun 2014 07:39:59 +0000 (09:39 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 9 Jan 2018 15:33:44 +0000 (16:33 +0100)
Improve reparenting static namespace functions to their presumably parent
structures. Only allow this if the first parameter is not defined as (out)
or (inout)

Unfortunately, while this patch fixes detection, nothing can be done about
breaking API.

Based on patch by Simon Werbeck <simon.werbeck@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=732460

vala/valagirparser.vala

index de5d7727cba7c66d0e50d45dfc9151f51c487651..7902e2d37f12a206038f0feb3313ce9158719079 100644 (file)
@@ -3942,10 +3942,10 @@ public class Vala.GirParser : CodeVisitor {
                var cname = node.get_cname ();
 
                Parameter first_param = null;
-               if (method.get_parameters ().size > 0) {
-                       first_param = method.get_parameters()[0];
+               if (node.parameters.size > 0) {
+                       first_param = node.parameters[0].param;
                }
-               if (first_param != null && first_param.variable_type is UnresolvedType) {
+               if (first_param != null && first_param.direction == ParameterDirection.IN && first_param.variable_type is UnresolvedType) {
                        // check if it's a missed instance method (often happens for structs)
                        var sym = ((UnresolvedType) first_param.variable_type).unresolved_symbol;
                        var parent = resolve_node (ns, sym);
@@ -3955,8 +3955,8 @@ public class Vala.GirParser : CodeVisitor {
                                if (parent.lookup (new_name) == null) {
                                        ns.remove_member (node);
                                        node.name = new_name;
+                                       node.parameters.remove_at (0);
                                        method.name = new_name;
-                                       method.get_parameters().remove_at (0);
                                        method.binding = MemberBinding.INSTANCE;
                                        parent.add_member (node);
                                }