www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Mixin name collisions that shouldn't be

reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
Try this.

import std.stdio;

class A
{
 template _B()
 {
  int C()
  {
   return 10;
  }

  int opCall()
  {
   return 15;
  }
 }

 mixin _B b;

 template _T()
 {
  int C()
  {
   return 20;
  }

  int opCall()
  {
   return 25;
  }
 }

 mixin _T t;
}

void main()
{
 A a=new A;
 writefln(a.b.C());
 writefln(a.t.C());

 // doesn't like these
 writefln(a.b());
 writefln(a.t());
}

For some reason, accessing a.b.C() and a.t.C() is just fine, but it doesn't 
like having those multiple opCalls, even though I'm fully qualifying their 
names. 
Mar 23 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jarrett Billingsley schrieb am Wed, 23 Mar 2005 17:02:22 -0500:
 Try this.

 import std.stdio;

 class A
 {
  template _B()
  {
   int C()
   {
    return 10;
   }

   int opCall()
   {
    return 15;
   }
  }

  mixin _B b;

  template _T()
  {
   int C()
   {
    return 20;
   }

   int opCall()
   {
    return 25;
   }
  }

  mixin _T t;
 }

 void main()
 {
  A a=new A;
  writefln(a.b.C());
  writefln(a.t.C());

  // doesn't like these
  writefln(a.b());
  writefln(a.t());
 }

 For some reason, accessing a.b.C() and a.t.C() is just fine, but it doesn't 
 like having those multiple opCalls, even though I'm fully qualifying their 
 names. 
Added to DStress as http://dstress.kuehne.cn/run/mixin_12.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCZrQ63w+/yD4P9tIRAkAvAJ0ey2nXJqIc5Km2FYEHJOUOtEwMQgCfSkT8 nYU7VnU3ZNBcISBQiMa2iN4= =MWEq -----END PGP SIGNATURE-----
Apr 20 2005