[Issue 14083] New: Remained unresolved forward reference issue with template classes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jan 30 07:09:58 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14083
Issue ID: 14083
Summary: Remained unresolved forward reference issue with
template classes
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
From: http://forum.dlang.org/thread/rggurpzmskjxesfelnwv@forum.dlang.org
Following code should work, but doesn't.
import std.stdio;
class Base(T)
{
public void Foo(A!T a)
{
writeln("Base.Foo(A a)");
}
public void Foo(B!T a)
{
writeln("Base.Foo(B a)");
}
}
class A(T) : Base!T
{
public T v;
this(T v)
{
this.v = v;
}
}
class B(T) : Base!T
{
public override void Foo(A!T a)
{
writeln("A: ", a.v);
}
}
int main()
{
A!int a = new A!(int)(1);
B!int b = new B!(int)();
a.Foo(b);
b.Foo(a);
return 0;
}
Output:
test.d(16): Error: class test.A!int.A is forward referenced when looking for
'v'
test.d(16): Error: class test.A!int.A is forward referenced when looking for
'opDot'
test.d(16): Error: class test.A!int.A is forward referenced when looking for
'opDispatch'
test.d(29): Error: no property 'v' for type 'test.A!int.A'
test.d(10): Error: template instance test.B!int error instantiating
test.d(16): instantiated from here: Base!int
test.d(35): instantiated from here: A!int
--
More information about the Digitalmars-d-bugs
mailing list