www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1996] New: is ( Type Identifier : TypeSpecialization ) deduction error with inheritance

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1996

           Summary: is ( Type Identifier : TypeSpecialization )  deduction
                    error with inheritance
           Product: D
           Version: 1.028
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


expressions of the form   
   is(Type U : Foo!(U)) 
do not work when Type is derived via inheritance from the template.

-----
module iface_specialize;

abstract class ACFoo(T)
{
    void init(T);
    void term();
    void blah();
    void bleh();
} 

class CFoo(T)
{
    void init(T) {}
    void term() {}
    void blah() {}
    void bleh() {}
} 

interface Foo(T)
{
    void init(T);
} 

class IsFoo(T) : Foo!(T) 
{
    override void init(T x) { }
}

class IsACFoo(T) : ACFoo!(T) 
{
    void init(T x) { }
}

class IsCFoo(T) : CFoo!(T) 
{
    void init(T x) { }
}

void main()
{
    alias IsFoo!(float) IsFoof;
    alias IsCFoo!(float) IsCFoof;
    alias IsACFoo!(float) IsACFoof;

    // These are ok
    static if (! is(IsFoof : Foo!(float))) {
        pragma(msg, "FAIL: IsFoof *is* a Foo!(float)");
    }
    static if (! is(IsCFoof : CFoo!(float))) {
        pragma(msg, "FAIL: IsCFoof *is* CFoo!(float)");
    }
    static if (! is(IsACFoof : ACFoo!(float))) {
        pragma(msg, "FAIL: IsACFoof *is* ACFoo!(float)");
    }

    // These fail
    static if (! is(IsFoof T : Foo!(T))) {
        pragma(msg, "FAIL: IsFoof *is* a Foo!(T) for some T [float]");
    }
    static if (! is(IsCFoof T : CFoo!(T))) {
        pragma(msg, "FAIL: IsCFoof *is* a CFoo!(T) for some T [float]");
    }
    static if (! is(IsACFoof T : ACFoo!(T))) {
        pragma(msg, "FAIL: IsACFoof *is* a ACFoo!(T) for some T [float]");
    }
}


-- 
Apr 14 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1996





------- Comment #1 from wbaxter gmail.com  2008-04-14 22:31 -------
It also doesn't work with DMD 2.012.


-- 
Apr 14 2008