www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Calling through an interface invokes the wrong method

reply "van eeshan" <vanee hotmail.net> writes:
Calling through an interface invokes the wrong method:

interface IOne
{
        void one ();
}

interface ITwo
{
        void two ();
}

interface IThree : IOne, ITwo
{
        void three ();
}

class Three : IThree
{
        void one ()
        {
                printf ("one\n");
        }

        void two ()
        {
                printf ("two\n");
        }

        void three ()
        {
                printf ("three\n");
        }
}


void main()
{
        IThree three = new Three;

        three.one();
        three.two();
        three.three();
}

print the following:

one
one
three

This clearly makes interfaces unusable at a rather fundamental level. Would
very much appreciate a fix asap.
Aug 04 2004
parent "van eeshan" <vanee hotmail.net> writes:
By the way: switching the order of the IThree declaration to this:

interface IThree : ITwo, IOne
{
        void three ();
}

produces this (incorrect) output instead:

two
two
three

I suppose if there's honor amongst thieves then there should be symmetry
within bugs. Can you perhaps give some indication when this might be
resolved please?


"van eeshan" <vanee hotmail.net> wrote in message
news:ces67k$rgj$1 digitaldaemon.com...
 Calling through an interface invokes the wrong method:

 interface IOne
 {
         void one ();
 }

 interface ITwo
 {
         void two ();
 }

 interface IThree : IOne, ITwo
 {
         void three ();
 }

 class Three : IThree
 {
         void one ()
         {
                 printf ("one\n");
         }

         void two ()
         {
                 printf ("two\n");
         }

         void three ()
         {
                 printf ("three\n");
         }
 }


 void main()
 {
         IThree three = new Three;

         three.one();
         three.two();
         three.three();
 }

 print the following:

 one
 one
 three

 This clearly makes interfaces unusable at a rather fundamental level.
Would
 very much appreciate a fix asap.
Aug 07 2004