November 03, 2015 Having some issues using Generator's yield with an interface | ||||
---|---|---|---|---|
| ||||
When I create a generator using an interface (or abstract class) I must cast the concrete instance to the interface. Why does the Generator not know that B is a implementation of the interface of A? /// Test Code interface A {} class B : A{} // Fails auto testGen1 = new Generator!A({ yield (new B()); }); // Succeeds auto testGen2 = new Generator!A({ yield ( cast(A) new B()); }); |
Copyright © 1999-2021 by the D Language Foundation