private ISymbolNode CreateMethodHandleHelper(MethodWithToken method, SignatureContext signatureContext)
{
+ bool useUnboxingStub = method.Method.IsUnboxingThunk();
+ if (useUnboxingStub)
+ {
+ method = new MethodWithToken(method.Method.GetUnboxedMethod(), method.Token, method.ConstrainedType);
+ }
+
bool useInstantiatingStub = method.Method.GetCanonMethodTarget(CanonicalFormKind.Specific) != method.Method;
return new PrecodeHelperImport(
_codegenNodeFactory.MethodSignature(
ReadyToRunFixupKind.READYTORUN_FIXUP_MethodHandle,
method,
- isUnboxingStub: false,
+ isUnboxingStub: useUnboxingStub,
isInstantiatingStub: useInstantiatingStub,
signatureContext));
}
break;
case CorInfoGenericHandleType.CORINFO_HANDLETYPE_METHOD:
- symbolNode = _compilation.SymbolNodeFactory.ReadyToRunHelper(
- ReadyToRunHelperId.MethodHandle,
- new MethodWithToken(HandleToObject(pResolvedToken.hMethod), HandleToModuleToken(ref pResolvedToken), constrainedType: null),
- GetSignatureContext());
+ {
+ MethodDesc md = HandleToObject(pResolvedToken.hMethod);
+ TypeDesc td = HandleToObject(pResolvedToken.hClass);
+
+ if (td.IsValueType)
+ {
+ md = _unboxingThunkFactory.GetUnboxingMethod(md);
+ }
+
+ symbolNode = _compilation.SymbolNodeFactory.ReadyToRunHelper(
+ ReadyToRunHelperId.MethodHandle,
+ new MethodWithToken(md, HandleToModuleToken(ref pResolvedToken), constrainedType: null),
+ GetSignatureContext());
+ }
break;
case CorInfoGenericHandleType.CORINFO_HANDLETYPE_FIELD: