[Issue 12884] New: implicit conversion wrongly prefers casting immutable away over alias this when target type is base class
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 9 15:37:01 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12884
Issue ID: 12884
Summary: implicit conversion wrongly prefers casting immutable
away over alias this when target type is base class
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: ASSIGNED
Keywords: wrong-code
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nilsbossung at googlemail.com
Reporter: nilsbossung at googlemail.com
---
class B {int x;}
class C : B
{
this(int x) pure {this.x = x;}
@property C mutable() const {return new C(42);}
alias mutable this;
}
void main()
{
immutable c = new C(1);
B m1 = c; /* should call alias this */
assert(m1.x == 42);
assert(m1 !is c);
}
---
Pull request is on the way.
--
More information about the Digitalmars-d-bugs
mailing list