From c500c79b17ce4b52c47821ec8381d3af42cdd235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 29 Apr 2025 11:24:36 +0100 Subject: [PATCH] Fix MethodBase::Invoke to handle generic instances - Now covering also generic-instance value type fixing up casting logic. --- .../CorLib/corlib_native_System_Reflection_MethodBase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp index 19651b81bc..2bef9433df 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp @@ -135,7 +135,10 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::Invoke___OBJECT__OBJ { if (mdR->retValDataType != DATATYPE_VOID) { - if (mdR->retValDataType < DATATYPE_I4) + // Types that need ChangeDataType: primitives and generic instances + bool needsTypeChange = (mdR->retValDataType < DATATYPE_I4 || mdR->retValDataType == DATATYPE_GENERICINST); + + if (needsTypeChange) { stack.TopValue().ChangeDataType(mdR->retValDataType); }