[Issue 11482] New: Add `alias this` support for `null` class instances
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 9 05:55:06 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11482
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 at puremagic.com
ReportedBy: verylonglogin.reg at gmail.com
--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at 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: -------
More information about the Digitalmars-d-bugs
mailing list