Permalink
Browse files

Generates valid IL code for the downcasting of a struct

  • Loading branch information...
xoofx committed Sep 27, 2015
1 parent 0671169 commit 8e2a1273411f915765d198d228d95ff0a0d385aa
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/Compilers/CSharp/Portable/CodeGen/EmitConversion.cs
@@ -24,6 +24,16 @@ private void EmitConversionExpression(BoundConversion conversion, bool used)
_builder.EmitIntConstant(0);
_builder.EmitOpCode(ILOpCode.Conv_u);
return;
case ConversionKind.ExplicitReference:
// Handle valuetype cast here
if (conversion.Type.IsValueType && conversion.Operand.Type.IsValueType)
{
EmitAddress(conversion.Operand, AddressKind.ReadOnly);
_builder.EmitOpCode(ILOpCode.Ldobj);
EmitSymbolToken(conversion.Type, conversion.Syntax);
return;
}
break;
}

if (!used && !conversion.ConversionHasSideEffects())

0 comments on commit 8e2a127

Please sign in to comment.