Skip to content

Commit

Permalink
Fix Type.GetHashCode for RuntimeTypes w/o MethodTable (dotnet#97195)
Browse files Browse the repository at this point in the history
The hashcode for these was always 0 before this change.
  • Loading branch information
jkotas authored and tmds committed Jan 23, 2024
1 parent 01c169e commit 300f0f0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ public override Array GetEnumValuesAsUnderlyingType()
}

public override int GetHashCode()
=> ((nuint)_pUnderlyingEEType).GetHashCode();
{
MethodTable* pEEType = _pUnderlyingEEType;
if (pEEType != null)
return ((nuint)pEEType).GetHashCode();
return RuntimeHelpers.GetHashCode(this);
}

public override RuntimeTypeHandle TypeHandle
{
Expand Down

0 comments on commit 300f0f0

Please sign in to comment.