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 554329 - [Tutorial] Interfaces without class prerequisites can't be used as variables
[Tutorial] Interfaces without class prerequisites can't be used as variables
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Objects
unspecified
Other All
: Normal minor
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-09-29 16:54 UTC by Lorenzo Delledonne
Modified: 2009-01-16 15:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Warn about a possibly missing GLib.Object prerequirement (1.45 KB, patch)
2009-01-08 20:43 UTC, Andreas Brauchli
committed Details | Review

Description Lorenzo Delledonne 2008-09-29 16:54:32 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.
Comment 1 Andreas Brauchli 2009-01-08 17:08:07 UTC
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.
Comment 2 Andreas Brauchli 2009-01-08 20:43:50 UTC
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?
Comment 3 Jürg Billeter 2009-01-16 15:47:39 UTC
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.