Skip to content

Commit

Permalink
Remove method shadowing with closure parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jwharm committed Sep 22, 2024
1 parent c2a8884 commit 9b353b2
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ public GirElement patch(GirElement element, String namespace) {
vm.platforms()
);

/*
* Some methods are shadowed by methods that take closures. This makes
* for a worse API in java-gi, and can also lead to issues with
* different parameter names when combining virtual methods with their
* invoker method in one Java method. Remove the shadowing.
*/
if (element instanceof Method m
&& m.callableAttrs().shadowedBy() != null
&& m.callableAttrs().shadowedBy().endsWith("_with_closures")) {
return m.withAttribute("shadowed-by", null);
}
if (element instanceof Method m
&& m.callableAttrs().shadows() != null
&& m.attr("name").endsWith("_with_closures")) {
return m.withAttribute("shadows", null);
}

return element;
}
}

0 comments on commit 9b353b2

Please sign in to comment.