www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12570] New: cast to template interface

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 puremagic.com
          Reporter: sigod.mail 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.

--
Apr 12 2014