diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 0fb27f215868..09301bef7ef1 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -15782,10 +15782,20 @@ bool Compiler::impReturnInstruction(BasicBlock* block, int prefixFlags, OPCODE& if (returnType != originalCallType) { - JITDUMP("Return type mismatch, have %s, needed %s\n", varTypeName(returnType), - varTypeName(originalCallType)); - compInlineResult->NoteFatal(InlineObservation::CALLSITE_RETURN_TYPE_MISMATCH); - return false; + // Allow TYP_BYREF to be returned as TYP_I_IMPL and vice versa + if (((returnType == TYP_BYREF) && (originalCallType == TYP_I_IMPL)) || + ((returnType == TYP_I_IMPL) && (originalCallType == TYP_BYREF))) + { + JITDUMP("Allowing return type mismatch: have %s, needed %s\n", varTypeName(returnType), + varTypeName(originalCallType)); + } + else + { + JITDUMP("Return type mismatch: have %s, needed %s\n", varTypeName(returnType), + varTypeName(originalCallType)); + compInlineResult->NoteFatal(InlineObservation::CALLSITE_RETURN_TYPE_MISMATCH); + return false; + } } // Below, we are going to set impInlineInfo->retExpr to the tree with the return