[Issue 1835] typeof(this) should return the type of object or some	other typeof() is needed
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Feb 14 06:44:00 PST 2008
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=1835
------- Comment #2 from aarti at interia.pl  2008-02-14 08:43 -------
Well, I requested it already before... Unfortunately without much luck:
1.
http://www.digitalmars.com/d/archives/digitalmars/D/Covariance_fix_was_Idea_Lazy_upcasting_51296.html
2.
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=51201
It's also mentioned in previous bugzilla reports:
1. http://d.puremagic.com/issues/show_bug.cgi?id=323
2. http://d.puremagic.com/issues/show_bug.cgi?id=1120
The problem solution seems to have even its name: anchored types.
----------------
Additionally in current design you have to overwrite every, even simple
setter/getter method in every derived class.
e.g.
class A {
  typeof(this) setX(int x) {
    this.x = x;
  }
  int x;
}
class B {
        void test() {}
}
When I don't want to redefine setX() in B, below also should work:
B b = new B;
b.setX(5).test;
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list