Hi,
We’ve run into an interesting issue in Unity 2019.3. When building for Android with IL2CPP, calling the overridden virtual method of an abstract class somehow causes the virtual base method to get called rather than the override method.
As an example, with the abstract base class Piece and implementation BasicPiece:
public abstract class Piece
{
// ...
public virtual Piece GetCopy()
{
throw new NotImplementedException();
}
}
public class BasicPiece : Piece
{
// ...
public override Piece GetCopy()
{
return new BasicPiece(Visual, _pieceColor);
}
}
The code above results in the following runtime error, on Android only:
2020-03-09 15:12:12.343 24791-24839/? E/Unity: NotImplementedException: The method or operation is not implemented.
at Piece.GetCopy () [0x00000] in <00000000000000000000000000000000>:0
...
Now, initially I thought this had to be a code mistake on our part. Surely GetCopy() isn’t actually getting overridden and we’re accidentally calling the base type. To verify, we replaced the virtual modifier on GetCopy() with abstract, like so:
public abstract class Piece
{
// ...
public abstract Piece GetCopy();
}
To our confusion, this version runs perfectly fine on Android with no runtime errors. No other changes were made.
Is there any chance we’re missing something simple here or did we maybe stumble into a new regression in IL2CPP?