When calling System.Object methods on structs (GetType, ToString, etc), previously the code was boxing the struct to pass as the instance parameter. The IMemoryLocation patch stopped this - the intention being to emit .constrained and then callvirt instead - but structs were falling through the gap, neither boxing nor emitting constrained/callvirt.

MSDN actually recommends that System.Object methods on value types always be emitted as constrained and callvirt instructions. From the docs for OpCode.Call:

"When calling methods of System.Object on value types, consider using the constrained prefix with the callvirt instruction instead of emitting a call instruction. This removes the need to emit different IL depending on whether or not the value type overrides the method, avoiding a potential versioning problem. Consider using the constrained prefix when invoking interface methods on value types, since the value type method implementing the interface method can be changed using a MethodImpl. These issues are described in more detail in the Constrained opcode."

This change implements that recommendation - ensuring that both 'this.' and 'base.' invocations of System.Object methods on value types are compiled as constrained virtual calls.
Merge pull request #139 from richard-fine/foreach

Fix System.Object method invocation on value types to be constrained