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 772381 - overrides with incompatible return types
overrides with incompatible return types
Status: RESOLVED FIXED
Product: tracker
Classification: Core
Component: General
git master
Other Linux
: Normal normal
: ---
Assigned To: tracker-general
tracker-general
Depends on:
Blocks: 641418
 
 
Reported: 2016-10-03 21:13 UTC by Matthias Berndt
Modified: 2016-10-05 13:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.50 KB, patch)
2016-10-03 21:13 UTC, Matthias Berndt
none Details | Review
Override Sparql.Connection.update_array_async() with correct return-type (3.66 KB, patch)
2016-10-04 09:11 UTC, Rico Tzschichholz
committed Details | Review

Description Matthias Berndt 2016-10-03 21:13:10 UTC
Created attachment 336840 [details] [review]
patch

Hey guys,

I'm working on fixing vala bug 641418: generic type parameters are ignored when type checking a method override.

Now, in tracker-bus.vala there's a place where you override a method that returns a GenericArray<Tracker.Sparql.Error?>? with one that returns a GenericArray<Glib.Error?>?.

Now, you might ask why the implementation typechecked then. Well, that seems to be another vala compiler bug :-(

I've attached a patch.
Comment 1 Matthias Berndt 2016-10-03 21:21:00 UTC
Correction: that the implementation typechecks is OK since errordomains all seem to be subtypes of Glib.Error. Anyway, the patch is still necessary :-)
Comment 2 Rico Tzschichholz 2016-10-04 08:00:02 UTC
The virtual method from tracker-connection.vala which is overridden here, is completely matching the definition used in tracker-bus.vala.

tracker-connection.vala:
public async virtual GenericArray<Error?>? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, GLib.Error, GLib.IOError, DBusError

tracker-bus.vala:
public async override GenericArray<Error?>? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, GLib.Error, GLib.IOError, DBusError

So this patch is not correct.
Comment 3 Matthias Berndt 2016-10-04 08:36:45 UTC
Hey Rico,

I still believe this patch is correct. "Error" is an unqualified identifier and can thus refer to different types in different contexts. In the context of tracker-connection.vala it refers to Tracker.Sparql.Error, in the context of tracker-bus.vala it refers to GLib.Error.
Comment 4 Rico Tzschichholz 2016-10-04 09:11:29 UTC
Created attachment 336861 [details] [review]
Override Sparql.Connection.update_array_async() with correct return-type

"Error" is an unqualified identifier and can thus refer to different types
in different contexts. In the context of tracker-connection.vala it refers
to Tracker.Sparql.Error, in the context of tracker-bus.vala it refers to
GLib.Error.
Comment 5 Rico Tzschichholz 2016-10-04 09:11:58 UTC
Right, better fully qualify those in all affected places.
Comment 6 Matthias Berndt 2016-10-04 09:17:42 UTC
It's not strictly necessary since the compiler will tell you once bug 641418 is fixed. But it doesn't hurt either and you can then just copy the declaration when you want to override it, so I suppose it's fine.
Comment 7 Matthias Berndt 2016-10-05 12:39:40 UTC
So what's the status here? Can the patch be merged?
Comment 8 Carlos Garnacho 2016-10-05 13:48:05 UTC
Comment on attachment 336861 [details] [review]
Override Sparql.Connection.update_array_async() with correct return-type

Makes sense indeed.
Comment 9 Rico Tzschichholz 2016-10-05 13:51:24 UTC
Attachment 336861 [details] pushed as 6446a48 - Override Sparql.Connection.update_array_async() with correct return-type