diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 7b849454fc00ff..1f7bca0825515e 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -4389,10 +4389,11 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, case NI_System_Type_get_IsPrimitive: // getTypeForPrimitiveValueClass returns underlying type for enums, so we check it first // because enums are not primitive types. - if ((info.compCompHnd->isEnum(hClass, nullptr) == TypeCompareState::MustNot) && - info.compCompHnd->getTypeForPrimitiveValueClass(hClass) != CORINFO_TYPE_UNDEF) + if (info.compCompHnd->isEnum(hClass, nullptr) == TypeCompareState::MustNot) { - retNode = gtNewTrue(); + CorInfoType type = info.compCompHnd->getTypeForPrimitiveValueClass(hClass); + retNode = + gtNewIconNode((type != CORINFO_TYPE_UNDEF) && (type != CORINFO_TYPE_VOID) ? 1 : 0); } else { diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index c965fa25c9dbd1..62b851ef379deb 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -157,6 +157,7 @@ private static void IsPrimitiveTests() IsTrue(typeof(IntPtr).IsPrimitive); IsTrue(typeof(UIntPtr).IsPrimitive); + IsFalse(typeof(void).IsPrimitive); IsFalse(typeof(Enum).IsPrimitive); IsFalse(typeof(ValueType).IsPrimitive); IsFalse(typeof(SimpleEnum).IsPrimitive);