@@ -133,17 +133,7 @@ public override void Emit(RHC rhc, ObjExpr objx, GenContext context)
133
133
if ( targetType != null && _tinfo != null )
134
134
{
135
135
_target . Emit ( RHC . Expression , objx , context ) ;
136
- // TODO: Transfer this mechanism for calls on value types to MethodExpr, InstanceZeroArityCallExpr, StaticFieldExpr
137
- if ( FieldDeclaringType . IsValueType )
138
- {
139
- ilg . Emit ( OpCodes . Unbox_Any , FieldDeclaringType ) ;
140
- LocalBuilder vtTemp = ilg . DeclareLocal ( FieldDeclaringType ) ;
141
- Compiler . MaybeSetLocalSymName ( context , vtTemp , "valueTemp" ) ;
142
- ilg . Emit ( OpCodes . Stloc , vtTemp ) ;
143
- ilg . Emit ( OpCodes . Ldloca , vtTemp ) ;
144
- }
145
- else
146
- ilg . Emit ( OpCodes . Castclass , FieldDeclaringType ) ;
136
+ MethodExpr . EmitPrepForCall ( context , typeof ( object ) , FieldDeclaringType ) ;
147
137
EmitGet ( ilg ) ;
148
138
HostExpr . EmitBoxReturn ( objx , context , FieldType ) ;
149
139
}
@@ -175,7 +165,7 @@ public override void EmitUnboxed(RHC rhc, ObjExpr objx, GenContext context)
175
165
if ( targetType != null && _tinfo != null )
176
166
{
177
167
_target . Emit ( RHC . Expression , objx , context ) ;
178
- ilg . Emit ( OpCodes . Isinst , targetType ) ;
168
+ MethodExpr . EmitPrepForCall ( context , typeof ( object ) , FieldDeclaringType ) ;
179
169
EmitGet ( ilg ) ;
180
170
}
181
171
else
0 commit comments