Re: [Vala] enum in a subclass



1) You can't use `override` for methods in interfaces, only for overriding
base classes.

2) The contents of `foo` are not in scope for `bar`, only they inherited
members because they are now part of `bar`. So `Type` in `bar` is
`GLib.Type` not `foo.Type`.

public interface foo
{
    public enum Type
    {
        a, b
    }

    public abstract Type get_type();
}

public class bar : foo
{
     foo.Type t = foo.Type.a;
     public new foo.Type get_type() { return t; }
}

3) You *really* *really* *really* don't want to name this method `get_type`
and you also don't want to name anything `Type` as these are used
underneath by GLib. The “fixed” version above will generate the following
broken C:

GType foo_get_type (void) G_GNUC_CONST;
fooType foo_get_type (foo* self);


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