Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not override return type for named constructors #160

Closed
jwharm opened this issue Dec 4, 2024 · 0 comments · Fixed by #179
Closed

Do not override return type for named constructors #160

jwharm opened this issue Dec 4, 2024 · 0 comments · Fixed by #179
Labels
bug Something isn't working

Comments

@jwharm
Copy link
Owner

jwharm commented Dec 4, 2024

"Named" and "unnamed" constructors are handled differently in Java:

  • Unnamed constructor foo_new(): a normal new Foo() {} constructor in Java
  • Named constructor foo_new_with_bar(): a factory method static Foo withBar() {} in Java
    Java-gi currently forces the return type of all constructors to be the enclosing type. But for a named constructor it is better to set the requested return type for the static method to the one that was specified in the gir file.

Note: Most Gtk constructors return Widget, regardless of the actual type, so for Gtk a workaround will be necessary to prevent a regression there.

This issue was logged as a follow-up to #156

@jwharm jwharm added the bug Something isn't working label Dec 4, 2024
@jwharm jwharm closed this as completed in 5e6dc20 Jan 2, 2025
jwharm added a commit that referenced this issue Jan 2, 2025
…cally.

For Gtk Widget constructors, override the return type with a GIR patch.

Fixes #160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant