[Issue 3537] Casting objects with alias this takes the subtype

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 9 05:52:47 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=3537


Jakob Ovrum <jakobovrum at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |jakobovrum at gmail.com
         Resolution|INVALID                     |


--- Comment #2 from Jakob Ovrum <jakobovrum at gmail.com> 2013-11-09 05:52:45 PST ---
(In reply to comment #1)
> This is designed behaviour. See documentation improvement Issue 11481.

It makes dynamic casts impossible, it has to be changed.

Here's a better example:
----
class A
{
    int i;
    alias i this;
}

class B : A {}

void main()
{
    A a = new B;
    B b = cast(B)a; // test.d(12): Error: e2ir: cannot cast a.i of type int to
type test.B
}
----

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