After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 784676 - vala does not handle G-I for which self can be nullable
vala does not handle G-I for which self can be nullable
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: GObject Introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-07 22:19 UTC by Christian Hergert
Modified: 2018-05-22 15:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vala: Methods annotated with NullableInstance allow "this == null" (3.00 KB, patch)
2017-09-03 15:21 UTC, Rico Tzschichholz
none Details | Review
vala: Methods annotated with NullableInstance allow "this == null" (6.03 KB, patch)
2017-09-03 16:58 UTC, Rico Tzschichholz
none Details | Review
vala: Methods annotated with NullableInstance allow "this == null" (6.61 KB, patch)
2017-09-03 17:44 UTC, Rico Tzschichholz
none Details | Review
vala: Methods annotated with NullableInstance allow "this == null" (6.68 KB, patch)
2017-09-03 19:38 UTC, Rico Tzschichholz
none Details | Review
Regenerate GIR-based bindings (23.13 KB, patch)
2017-09-03 19:39 UTC, Rico Tzschichholz
none Details | Review

Description Christian Hergert 2017-07-07 22:19:04 UTC
Some C API for objects allow NULL for the interface functions to use a fallback implementation. Setting (nullable) for @self in that API causes incompatible signatures in interface implementations in Vala.

This should be safe, as by design, you can't ever jump into vala code with a NULL instance.

Example:

/**
 * foo_do_something:
 * @self: (nullable): A #Foo or %NULL
 *
 * Do something. If foo is %NULL, a fallback implementation
 * is provided.
 */
void
foo_do_something (Foo *foo)
{
  if (foo)
    FOO_GET_IFACE (foo)->do_something (foo);
  else
    do_fallback ();
}
Comment 1 Rico Tzschichholz 2017-09-03 15:21:49 UTC
Created attachment 359029 [details] [review]
vala: Methods annotated with NullableInstance allow "this == null"
Comment 2 Rico Tzschichholz 2017-09-03 15:25:52 UTC
Could you provide an actual project with GIR file for this?
Comment 3 Rico Tzschichholz 2017-09-03 16:58:21 UTC
Created attachment 359034 [details] [review]
vala: Methods annotated with NullableInstance allow "this == null"

If a method is suppose to allow a null-instance then don't perform
the usual type-/null-check.

Make girparse able to recognize nullable instance-parameters and
add support for boolean "nullable-instance" metadata.
Comment 4 Rico Tzschichholz 2017-09-03 17:44:10 UTC
Created attachment 359035 [details] [review]
vala: Methods annotated with NullableInstance allow "this == null"

If a method is suppose to allow a null-instance then don't perform
the usual type-/null-check.

Make girparse able to recognize nullable instance-parameters and
add support for boolean "nullable-instance" metadata.
Comment 5 Christian Hergert 2017-09-03 18:37:52 UTC
https://git.gnome.org/browse/gnome-builder/commit/?id=5373d8a was what was breaking before, but I can't seem to replicate it at all. So I'm a bit at a loss of how it was breaking before.

Lets see if any if any distros complain about builds, but since this seems to work I have no more issues.
Comment 6 Rico Tzschichholz 2017-09-03 19:38:38 UTC
Created attachment 359040 [details] [review]
vala: Methods annotated with NullableInstance allow "this == null"

If a method is suppose to allow a null-instance then don't perform
the usual type-/null-check.

Make girparse able to recognize nullable instance-parameters and
add support for boolean "nullable-instance" metadata.
Comment 7 Rico Tzschichholz 2017-09-03 19:39:01 UTC
Created attachment 359041 [details] [review]
Regenerate GIR-based bindings
Comment 8 GNOME Infrastructure Team 2018-05-22 15:50:20 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/589.