[Issue 6434] opDispatch must be considered before alias this.
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Oct 23 22:30:06 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6434
--- Comment #8 from Kenji Hara <k.hara.pg at gmail.com> 2011-10-23 22:29:00 PDT ---
Reopened pull request.
https://github.com/D-Programming-Language/dmd/pull/349
Points:
1. alias this lookup should be considered first.
   It is the synonym of super-class.
2. If alias this lookup fails, *most derived* opDispatch should be used.
// From
https://github.com/D-Programming-Language/dmd/pull/349#issuecomment-1923037
struct A
{
  int opDispatch(string s)() { return 1; }
}
struct B
{
  A a;
  alias a this;
  int opDispatch(string s)() if (s == "bsfunc") { return 2; }
}
void main()
{
  B b;
  assert(b.bsfunc() == 2);
  assert(b.notfoundanywhere() == 1);  // *1
}
The most derived opDispatch from B is B.opDispatch, then b.xxx is always
transformed to b.opDispatch!("xxx").
Therefore, line *1 doesn't compile, and A.opDispatch is never used.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list