[Issue 1996] New: is ( Type Identifier : TypeSpecialization ) deduction error with inheritance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 14 20:25:17 PDT 2008


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 at digitalmars.com
        ReportedBy: wbaxter at 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]");
    }
}


-- 



More information about the Digitalmars-d-bugs mailing list