[Issue 2050] interfaces should allow final methods with body

Robert Fraser fraserofthenight at gmail.com
Mon Apr 28 03:09:00 PDT 2008


d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=2050
> 
> 
> aarti at interia.pl changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |aarti at interia.pl
> 
> 
> 
> 
> ------- Comment #3 from aarti at interia.pl  2008-04-28 03:56 -------
> It seems that same rationale applies to static functions in interfaces.
> Currently below code doesn't work, as static functions can not have body in
> interface.
> 
> ---
> int a;
> interface A {
>   static int number() {
>     return a;
>   }
> }
> ---
> 
> Current situation is just plainly wrong as it is possible to put static
> functions into interfaces and it is not possible to use them at all - linker
> error is emitted during compilation (what is understandable as static functions
> are not virtual).

You should be able to call them on the interface: If you have:

class B : A {}

void main()
{
     A a = new B();
     B b = new B();

     A.number(); // Should work fine, so here's the bug
     a.number(); // Maybe should work....?
     b.number(); // Should NOT work
}


More information about the Digitalmars-d-bugs mailing list