[Issue 6570] New: 'this' silently passes from one object to another

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 29 03:42:59 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6570

           Summary: 'this' silently passes from one object to another
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: alienballance at gmail.com


--- Comment #0 from Mariusz Gliwiński <alienballance at gmail.com> 2011-08-29 03:42:57 PDT ---
<code>
import std.stdio;

class T {
    abstract string type() {
        return "T";
    }
}

class T2 : T {
    override string type() {
        return "T2";
    }
    void test(T)() {
        writeln(T.type);
    }
}

void main() {
    (new T2).test!T();
}
</code>
<output>T2</output>
type() isn't static method so AFAIK it shouldn't be possible to call it from
test(). Instead of that, call is possible, and local 'this' is 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