D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1996 - is ( Type Identifier : TypeSpecialization ) deduction error with inheritance
Summary: is ( Type Identifier : TypeSpecialization ) deduction error with inheritance
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-04-14 22:25 UTC by Bill Baxter
Modified: 2014-02-24 15:33 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bill Baxter 2008-04-14 22:25:16 UTC
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]");
    }
}
Comment 1 Bill Baxter 2008-04-14 22:31:55 UTC
It also doesn't work with DMD 2.012.
Comment 2 yebblies 2011-06-12 22:29:59 UTC
All tests now pass with current dmd (1.068 & 2.053)