GNOME Bugzilla – Bug 587030
instanceof Gtk.FileChooser not implemented
Last modified: 2016-11-29 05:45:30 UTC
const Gtk = imports.gi.Gtk; log(42 instanceof Gtk.FileChooser); Error: API of type INTERFACE not implemented, cannot define Gtk.FileChooser
Almost three years later, probably one loses interest... anyway I've implemented it :) It's not strictly necessary to have it in 3.4, but it should be pretty safe and fixes one clear annoyance.
Created attachment 208888 [details] [review] Interface: add support for instanceof Rework the way interface objects are exposed, so that obj instanceof My.Interface does the expected thing when obj is a GObject.
Review of attachment 208888 [details] [review]: Not a fan of the implementation.
(In reply to comment #3) > Review of attachment 208888 [details] [review]: > > Not a fan of the implementation. Neither I am, but there doesn't seem to be a better way to implent it. The interpreter looks only at the JSClass of right hand side of instanceof, which is js_FunctionClass, unless we introduce this hack.
FWIW, this would be solved by a patch on https://bugzilla.gnome.org/show_bug.cgi?id=751343 where you could do Gtk.FileChooserButton.implements(Gtk.FileChooser) // --> true let button = new Gtk.FileChooserButton(); button.constructor.implements(Gtk.FileChooser) // --> true It's unclear to me how "instanceof" will interact with ES6 classes/interfaces, so that was the rationale for not doing it with "instanceof".
Going to close this one and stick with Lang.Class.implements(), since that's what we have now, and it doesn't change the expected semantics of "instanceof".