On Tuesday, 27 October 2015 at 07:52:27 UTC, Jacob Carlborg wrote:
[...] I don't think this is possible. Think of code looking like this:// Imagine not having access to the source code "createA" A createA() { new B; } void inspectA(A a) { a.bar(); }How should the compiler know that when instantiating/calling "bar", T should be set to B? The compiler might not even know about B exists at all. Even if the compiler does have access to the complete source code it would, most likely, need to do a full program analyze to figure out the type of T, which is quite complicated.
The method is instantiated when the subclass is defined so T would obviously be right on hand. Sub-classing a class with an auto override method would implicitly instantiate and override the method. Calling a.bar() would have no problems because bar would be virtual.
