[Issue 6579] Calling static method should *require* using type and not instance, unless specified by author

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 3 06:49:46 PDT 2012


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


timon.gehr at gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr at gmx.ch


--- Comment #6 from timon.gehr at gmx.ch 2012-06-03 06:51:42 PDT ---
(In reply to comment #4)
> It hinders overloading. For so long I wanted to be able to have both static and
> non-static opDispatch and opCall and couldn't because of this. This behavior is
> not doing any good anyway.

This issue is not closely related to overloading.
Slightly refining the overloading rules as proposed in issue 3345 would already
solve the problem.

struct S{
    static void foo(){...}
    void foo(){...}
}

struct T{
    static void foo(){...}
    void bar(){...}
}

void main(){
    S s; T t;
    S.foo(); // calls the static version
    s.foo(); // calls the instance version
    T.foo(); // ok
    t.foo(); // ok
    // T.bar() // error
    t.bar(); // ok
}

-- 
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