super-interfaces

Bill Baxter dnewsgroup at billbaxter.com
Tue Apr 24 20:50:40 PDT 2007


Chris Nicholson-Sauls wrote:
> Bill Baxter wrote:
>> I think this may be a bug with super-interfaces.
>> It's telling me that something is not an override, when, in fact, it is.
>>
>> Here's the setup:
>>
>> interface Fruit
>> {
>>    ...  // some methods
>> }
>> interface Vehicle
>> {
>>    void drive_around();
>>    ...  // some other methods
>> }
>> interface MobileFruit : Fruit, Vehicle
>> {
>>    // nothing here, should inherit from superinterfaces
>> }
>>
>> class BaseFruit : Fruit
>> {
>>    // implement (some of) Fruit's methods here
>> }
>>
>> class MobileFruitGundam : BaseFruit, MobileFruit
>> {
>>    // implement what's not in BaseFruit already
>>
>>    override void drive_around() {..} // from Vehicle
>> }
>>
>> The last part doesn't work.  It tells me that drive_around is not an 
>> override.  But it works if I don't tag it with 'override'.
>>
>> Is that a bug?
>>
>> --bb
> 
> I don't think it is.  As I understand it, 'override' only masks a 
> virtual function implementation or 'abstract' placeholder.  Interfaces 
> do not provide implementations nor placeholders, only a contract 
> requiring certain signatures exist.  The main use of 'override' is to 
> catch non-back-compatible API changes.
> 
> -- Chris Nicholson-Sauls

Huh, well I routinely use override on things I inherit from interfaces.

This generates no errors:
interface Fruit
{
     void eat();
}
class YummyFruit : Fruit
{
     override void eat() {
        writefln("That's yummy");
     }
}

So you're opinion is that the spec says that should be an error?

--bb


More information about the Digitalmars-d-bugs mailing list