The importer folds Type.IsPrimitive for a known System.Void type handle to true, disagreeing with reflection, which reports false for typeof(void).IsPrimitive.
Minimal Repro
using System;
using System.Runtime.CompilerServices;
class Program
{
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
static bool Folded() => typeof(void).IsPrimitive;
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
static bool Runtime(Type t) => t.IsPrimitive;
static void Main()
{
Console.WriteLine("folded: " + Folded());
Console.WriteLine("runtime: " + Runtime(typeof(void)));
}
}
Expected
folded: False
runtime: False
Actual
folded: True
runtime: False
Notes
Compiler::impIntrinsic handles NI_System_Type_get_IsPrimitive by checking getTypeForPrimitiveValueClass, which returns a primitive type value for System.Void.
The fold should explicitly reject CORINFO_TYPE_VOID so it matches System.Type.IsPrimitive.
The importer folds
Type.IsPrimitivefor a knownSystem.Voidtype handle totrue, disagreeing with reflection, which reportsfalsefortypeof(void).IsPrimitive.Minimal Repro
Expected
Actual
Notes
Compiler::impIntrinsichandlesNI_System_Type_get_IsPrimitiveby checkinggetTypeForPrimitiveValueClass, which returns a primitive type value forSystem.Void.The fold should explicitly reject
CORINFO_TYPE_VOIDso it matchesSystem.Type.IsPrimitive.