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 547362 - Interfaces complaining about missing prerequisite when used as variable types.
Interfaces complaining about missing prerequisite when used as variable types.
Status: RESOLVED NOTABUG
Product: vala
Classification: Core
Component: Semantic Analyzer
0.3.x
Other All
: Normal major
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-12 00:09 UTC by Mart Roosmaa
Modified: 2008-09-29 16:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase demonstrating the problem. (207 bytes, text/plain)
2008-08-12 00:10 UTC, Mart Roosmaa
Details
Example code adapted from the official tutorial (369 bytes, text/plain)
2008-09-28 21:58 UTC, Lorenzo Delledonne
Details

Description Mart Roosmaa 2008-08-12 00:09:53 UTC
When trying to use interfaces as a common type name for variables or generic classes (eg: List) the valac reports the following error:
---
testcase.vala:18.14-18.14: error: missing class prerequisite for interface `IFoo'
    IFoo i = o;
             ^
testcase.vala:14.26-14.29: error: missing class prerequisite for interface `IFoo'
    var list2 = new List<IFoo>();
                         ^^^^
testcase.vala:18.5-18.8: error: missing class prerequisite for interface `IFoo'
    IFoo i = o;
    ^^^^
---

Testcase attached.
(Running Vala from SVN r1748)
Comment 1 Mart Roosmaa 2008-08-12 00:10:18 UTC
Created attachment 116393 [details]
Testcase demonstrating the problem.
Comment 2 Lorenzo Delledonne 2008-09-28 21:55:09 UTC
Maybe I can confirm this bug:
I'm currently unable to get interfaces working in Vala.

When trying to compile the official Tutorial's interface example (see the attachment), I get this error:

------------

pikkio:vala % valac -o interfaces interfaces.vala
interfaces2.vala:22.13-22.13: error: missing class prerequisite for interface `ITest'
		ITest i = t;
		          ^
interfaces2.vala:22.3-22.7: error: missing class prerequisite for interface `ITest'
		ITest i = t;
		^^^^^
Compilation failed: 2 error(s), 0 warning(s)

------------

I don't have adequate Vala knowledge to confirm this, but it looks like the same bug.
P.S. I'm using libvala version 0.3.5 on Ubuntu Hardy Backports.
Comment 3 Lorenzo Delledonne 2008-09-28 21:58:26 UTC
Created attachment 119549 [details]
Example code adapted from the official tutorial
Comment 4 Jürg Billeter 2008-09-29 07:13:43 UTC
Interfaces without class prerequisites can't be used as variables as there is no memory management associated with them. The following example should work fine:

public interface ITest : Object {
	public abstract int data_1 { get; set; }
	public abstract void function_1 ();
}

public class Test1 : Object, ITest {
	public int data_1 { get; set; }
	public void function_1 () {
	}
}

static void main () {
	Test1 t = new Test1();
	t.function_1 ();

	ITest i = t;
	i.function_1 ();
}
Comment 5 Lorenzo Delledonne 2008-09-29 16:57:47 UTC
Thanks, I've filed the Bug #554329 against the Vala tutorial, as may lead to this kind of misinterpretation.