Fix getting typecode of generic parameters restricted to be Enum (#82029)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Mon, 13 Feb 2023 15:04:25 +0000 (00:04 +0900)
committerGitHub <noreply@github.com>
Mon, 13 Feb 2023 15:04:25 +0000 (07:04 -0800)
Found in JIT tests.

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Augments/ReflectionAugments.cs

index 48e00e0..638d6f8 100644 (file)
@@ -48,7 +48,7 @@ namespace Internal.Reflection.Augments
             {
                 // Type exists in metadata only. Aside from the enums, there is no chance a type with a TypeCode would not have an MethodTable,
                 // so if it's not an enum, return the default.
-                if (!type.IsEnum)
+                if (!type.IsEnum || type.IsGenericParameter)
                     return TypeCode.Object;
                 Type underlyingType = Enum.GetUnderlyingType(type);
                 eeType = underlyingType.TypeHandle.ToEETypePtr();