diff --git a/src/CLR/Core/CLR_RT_HeapBlock.cpp b/src/CLR/Core/CLR_RT_HeapBlock.cpp index fc878bcc80..3f340f7cec 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock.cpp @@ -294,31 +294,6 @@ HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_MethodDef_Index &md) NANOCLR_NOCLEANUP(); } -HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_GenericParam_Index &gp) -{ - NATIVE_PROFILE_CLR_CORE(); - NANOCLR_HEADER(); - - CLR_RT_GenericParam_Instance genericParam; - CLR_RT_TypeDef_Index typeDef; - - if (genericParam.InitializeFromIndex(gp) == false) - { - NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); - } - - // grab the type definition from the generic param - typeDef = genericParam.CrossReference().classTypeDef; - - m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1); - m_data.reflection.levels = 0; - m_data.reflection.kind = REFLECTION_TYPE; - // set the type definition in the reflection block - m_data.reflection.data.type.Set(typeDef.Assembly(), typeDef.Type()); - - NANOCLR_NOCLEANUP(); -} - HRESULT CLR_RT_HeapBlock::SetObjectCls(const CLR_RT_TypeDef_Index &cls) { NATIVE_PROFILE_CLR_CORE(); diff --git a/src/CLR/Core/Interpreter.cpp b/src/CLR/Core/Interpreter.cpp index 51595099ef..af4aa47a4b 100644 --- a/src/CLR/Core/Interpreter.cpp +++ b/src/CLR/Core/Interpreter.cpp @@ -3240,7 +3240,30 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - evalPos[0].SetReflection(param); + if (stack->m_call.genericType != nullptr) + { + // For a method in a generic type, caller->genericType points to the TypeSpec of the + // closed type + CLR_UINT32 closedTypeSpecRow = stack->m_call.genericType->TypeSpec(); + + CLR_RT_TypeDef_Index resolvedTypeDef; + NanoCLRDataType resolvedDataType; + + CLR_UINT32 index = CLR_DataFromTk(arg); + + assm->FindGenericParamAtTypeSpec( + closedTypeSpecRow, + index, + resolvedTypeDef, + resolvedDataType); + + evalPos[0].SetReflection(resolvedTypeDef); + } + else + { + // No caller context?? + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } } break; diff --git a/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h b/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h index e7b33e8434..4205d6a99d 100644 --- a/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h +++ b/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h @@ -1351,7 +1351,6 @@ struct CLR_RT_HeapBlock HRESULT SetReflection(const CLR_RT_TypeDef_Index &cls); HRESULT SetReflection(const CLR_RT_FieldDef_Index &fd); HRESULT SetReflection(const CLR_RT_MethodDef_Index &md); - HRESULT SetReflection(const CLR_RT_GenericParam_Index &gp); HRESULT InitializeArrayReference(CLR_RT_HeapBlock &ref, int index); void InitializeArrayReferenceDirect(CLR_RT_HeapBlock_Array &array, int index);