Closed tritao closed 9 years ago
@tritao I tried to reproduce it but could not because probably I didn't quite understand it. Please explain this a bit...
@genuinelucifer imagine that in the Base of the example you have a virtual function defined as follows:
int Base::virtualFunction()
{
return 1;
}
Then in the Derived from the example you override this function:
int Derived::virtualFunction()
{
return 2;
}
At present, when you call b.virtualFunction() - as in the definition of the issue - you'll get 1. However, this is wrong - you should get 2 because the real C++ type that is returned is Derived.
@genuinelucifer You need to use the same code we use for calls in abstract implementations:
@ddobrev Thanks. Will try to implement it.
@ddobrev Please see #496. I have tried but the test is failing at one instance. It feels a bit weird to me.
Consider this case:
C++:
static Base getBase() { return Derived(); }
C#:
Base b = Base.getBase(); b.virtual();
Since we're not generating code to go through the virtual table in
Base
we'll not have the expected polymorphic behaviour.