Bug 14083 – Remained unresolved forward reference issue with template classes

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-30T15:09:00Z
Last change time
2015-01-30T22:02:49Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2015-01-30T15:09:58Z
From: http://forum.dlang.org/thread/[email protected] 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
Comment #1 by k.hara.pg — 2015-01-30T15:56:36Z
Comment #2 by github-bugzilla — 2015-01-30T22:02:49Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6d59dd758b09a233d8262eebbd58fd80324f0435 fix Issue 14083 - Remained unresolved forward reference issue with template classes https://github.com/D-Programming-Language/dmd/commit/256fedad25f452b733d7413683477b36fbd3f68d Merge pull request #4358 from 9rnsr/fix14083 Issue 14083 - Remained unresolved forward reference issue with template classes