[Vala] Interfaces - why do they must have prerequisites?



Hi all,

I'm using valac 0.11.2, and when I compile the following code, it fails:

// ------- test.vala -------
namespace Test
{
        public interface IFoo
        {
                public abstract bool run();
        }
        
        public class Foo : IFoo
        {
                public virtual bool run()
                {
                        return true;
                }
        }
        
        public static void main()
        {
                IFoo ifoo = new Foo();
                ifoo.run();
                return;
        }
}
// ----- end test.vala -----

The compiler fails with the following error:

$ valac test.vala 
test.vala:18.3-18.6: error: missing class prerequisite for interface
`Test.IFoo', add GLib.Object to interface declaration if unsure
        IFoo ifoo = new Foo(); 
        ^^^^ 
test.vala:18.3-18.6: error: missing class prerequisite for interface
`Test.IFoo', add GLib.Object to interface declaration if unsure 
        IFoo ifoo = new Foo(); 
        ^^^^ 
Compilation failed: 2 error(s), 0 warning(s)

When I make IFoo dependant on Object, and Foo inheriting Object, the
problem is gone.

Please can you tell me, is now prerequisiting interface on a class
always needed? http://live.gnome.org/Vala/Manual/Interfaces suggests
that it's optional...

best regards,
AW.

-- 
Mój klucz publiczny o identyfikatorze 1024D/E12C5A4C znajduje się na
serwerze hkp://keys.gnupg.net

My public key with signature 1024D/E12C5A4C is on the server
hkp://keys.gnupg.net

Attachment: signature.asc
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]