Bug 1996 – is ( Type Identifier : TypeSpecialization ) deduction error with inheritance
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-04-14T22:25:00Z
Last change time
2014-02-24T15:33:40Z
Keywords
rejects-valid
Assigned to
nobody
Creator
wbaxter
Comments
Comment #0 by wbaxter — 2008-04-14T22:25:16Z
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 by wbaxter — 2008-04-14T22:31:55Z
It also doesn't work with DMD 2.012.
Comment #2 by yebblies — 2011-06-12T22:29:59Z
All tests now pass with current dmd (1.068 & 2.053)