GNOME Bugzilla – Bug 554329
[Tutorial] Interfaces without class prerequisites can't be used as variables
Last modified: 2009-01-16 15:47:39 UTC
Documentation Section: In the "Interface" section ov the Vala tutorial, on http://live.gnome.org/Vala/Tutorial#head-550883e2f1aeebc10f4d160561df2907ff79255c In the "Interfaces" section of the Vala tutorial, interface definitions are not fully explained, and may easily lead to misinterpretations. The following interface example doesn't compile: -------- public interface ITest { public abstract int data_1 { get; set; } public abstract void function_1(); } -------- -------- public class Test1 : ITest { public int data_1 { get; set; } public void function_1() { } } -------- -------- Test1 t = new Test1(); t.function_1(); ITest i = t; i.function_1(); -------- (The error is: "missing class prerequisite for interface") Correct version: It should be clarified that such a use of interfaces needs them to have a class as prerequisite (e.g. GLib.Object), and the code example should be modified accordingly. Other information: The bug/Not-A-Bug #547362 should help to clarify this issue.
it requires the unowned (previously weak) keyword since the interface does not implement a copy/ref function you could alternatively simply work around this by setting GLib.Object as prerequisite to the interface fixed in the tutorial, this should be closed.
Created attachment 126054 [details] [review] Warn about a possibly missing GLib.Object prerequirement Should we also hint that the error comes from the missing dup/ref function?
2009-01-16 Jürg Billeter <j@bitron.ch> * gobject/valaccodebasemodule.vala: Warn about possibly missing GLib.Object prerequisite, patch by Andreas Brauchli, fixes bug 554329 Fixed in r2352.