www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11482] New: Add `alias this` support for `null` class instances


           Summary: Add `alias this` support for `null` class instances
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com

--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-11-09
16:55:04 MSK ---
As `alias this` may be used to inheritance support a conversion from base to
derived is expected to work also for `null` class instances.

A possible solution as to allow aliasing static or non-member function which
accepts the type as a parameter:
class A { }

A asA(B b) { return b ? b.a : null; }

class B
    A a;
    alias asA this;

void main()
    B b = null;
    A a = b; // rewritten as `asA(b)`

Based on Issue 2929.

Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 09 2013