[Issue 12570] New: cast to template interface

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 12 16:34:53 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12570

          Issue ID: 12570
           Summary: cast to template interface
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: sigod.mail at gmail.com

Consider this code:

////////////////////////////////
import std.stdio;

interface A {}
interface B(T : A) : A {}

class C_a : A {}
class B_a : B!C_a {}

void main()
{
    B_a b = new B_a;

    B!A b_a = b;

    writeln(b_a);
}
////////////////////////////////

Compiler says:
Error: cannot implicitly convert expression (b) of type B_a to B!(A).B

Shouldn't it be allowed?

However, explicit cast result in null.

--


More information about the Digitalmars-d-bugs mailing list