GNOME Bugzilla – Bug 772381
overrides with incompatible return types
Last modified: 2016-10-05 13:51:29 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.
Correction: that the implementation typechecks is OK since errordomains all seem to be subtypes of Glib.Error. Anyway, the patch is still necessary :-)
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.
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.
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.
Right, better fully qualify those in all affected places.
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.
So what's the status here? Can the patch be merged?
Comment on attachment 336861 [details] [review] Override Sparql.Connection.update_array_async() with correct return-type Makes sense indeed.
Attachment 336861 [details] pushed as 6446a48 - Override Sparql.Connection.update_array_async() with correct return-type