Why callvirtdoes the compiler generate a command to call the method of the explicitly implemented interface and callto call the method of the implemented interface implicilty in the following code?
The compiler was mono mcs4.2.2 with optimization enabled.
public interface ITest
{
void ExplicitInterfaceMethod();
void ImplicitInterfaceMethod();
}
public sealed class Test : ITest
{
void ITest.ExplicitInterfaceMethod()
{ }
public void ImplicitInterfaceMethod()
{ }
public void InstanceMethod()
{ }
public void CallTest()
{
((ITest) this).ExplicitInterfaceMethod();
this.ImplicitInterfaceMethod();
InstanceMethod();
}
}
What I have found out so far:
callvirtused for a "receiver with a null value" because it performs a null check before fixing a jump to a method. It seems thisto be null. ( Call and Callvirt )call used if the compiler can prove that the receiver is not zero.- ,
callvirt, . ( .)
, this , .
?
this null?
, - , . , this null , call ?
@jonathon-chase , : , , "", / . , callvirt, . (. ).
:
sealed, . , 1) , 2) this, 3) - sealed; . , call, , , .