Open chschrae opened 3 weeks ago
Based on local testing, it looks like both mono x86 jit and mono interpreter also do this incorrectly.
As an interim workaround, a construction like this appears to work:
public class BasicDerivedClass : BasicBaseClass, IBaseInterface<BasicBaseClass>, IBaseInterface<BasicDerivedClass>
{
string className = "BasicDerivedClass";
string IBaseInterface<BasicBaseClass>.explicitDeclaration()
{
return className;
}
string IBaseInterface<BasicDerivedClass>.explicitDeclaration()
{
return className;
}
}
I'm guessing whatever your real scenario is might make it impossible to apply this as a workaround though.
Description
When using an interface with a generic out type, an explicit implementation, and a derived class, the base classes implementation is called instead of the derived class when running on Android. Running on Windows yields the expected behavior.
Reproduction Steps
Given an interface:
and a couple of classes:
You can then create some objects in a list and iterate over them to call their function:
Expected behavior
I would expect the behavior to be the same on Android and Windows.
Actual behavior
The printouts you will see when running on Windows is:
and when running on Android:
Regression?
No response
Known Workarounds
No response
Configuration
.NET 8 Android 33 and Windows x64
Other information
This only occurs with explicit interface declarations. If you simply hide the base implementation, the issue does not occur. This is true for implicit hiding, 'new' keyword, and overriding virtual functions.