From: Rico Tzschichholz Date: Fri, 4 Mar 2022 10:45:41 +0000 (+0100) Subject: girparser: Don't count instance-parameter when checking for backwards closure reference X-Git-Tag: 0.54.8~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f021e1b0b50cb9f9e5cc7cb2c9cc49fdbc8070e;p=thirdparty%2Fvala.git girparser: Don't count instance-parameter when checking for backwards closure reference Fixes https://gitlab.gnome.org/GNOME/vala/issues/721 --- diff --git a/tests/gir/delegate-closure-destroy-index-conflict.test b/tests/gir/delegate-closure-destroy-index-conflict.test index 4bf57bfa6..449136c90 100644 --- a/tests/gir/delegate-closure-destroy-index-conflict.test +++ b/tests/gir/delegate-closure-destroy-index-conflict.test @@ -2,6 +2,40 @@ GIR Input: + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -21,5 +55,12 @@ Input: Output: +[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")] +public class Foo : GLib.Object { + [CCode (has_construct_function = false)] + protected Foo (); + [CCode (cname = "test_function")] + public void function (owned GLib.Func? callback); +} [CCode (cheader_filename = "test.h")] public static void function (owned GLib.Func? callback); diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala index a66e5d706..cef4f5684 100644 --- a/vala/valagirparser.vala +++ b/vala/valagirparser.vala @@ -3470,11 +3470,13 @@ public class Vala.GirParser : CodeVisitor { var current_parameter_idx = -1; while (current_token == MarkupTokenType.START_ELEMENT) { - current_parameter_idx++; - var is_instance_parameter = (reader.name == "instance-parameter" && !(symbol_type == "function" || symbol_type == "constructor")); + if (!is_instance_parameter) { + current_parameter_idx++; + } + if (instance_idx > -2 && instance_idx == current_parameter_idx) { skip_element (); continue;