Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Nullable<> support
  • Loading branch information
EgorBo committed Feb 11, 2021
commit f49b89e1e5d0e87625ca1c36ddb1af9ddabf7213
1 change: 1 addition & 0 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ DEFINE_CLASS(OBJECT_EQUALITYCOMPARER, CollectionsGeneric, ObjectEqualityComparer
DEFINE_CLASS(GENERIC_COMPARER, CollectionsGeneric, GenericComparer`1)
DEFINE_CLASS(OBJECT_COMPARER, CollectionsGeneric, ObjectComparer`1)
DEFINE_CLASS(ENUM_COMPARER, CollectionsGeneric, EnumComparer`1)
DEFINE_CLASS(NULLABLE_COMPARER, CollectionsGeneric, NullableComparer`1)

DEFINE_CLASS(INATTRIBUTE, Interop, InAttribute)

Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9122,6 +9122,18 @@ CORINFO_CLASS_HANDLE CEEInfo::getDefaultComparerClassHelper(CORINFO_CLASS_HANDLE
return CORINFO_CLASS_HANDLE(resultTh.GetMethodTable());
}

// Nullable<T>
if (Nullable::IsNullableType(elemTypeHnd))
{
Instantiation nullableInst = elemTypeHnd.AsMethodTable()->GetInstantiation();
TypeHandle iequatable = TypeHandle(CoreLibBinder::GetClass(CLASS__IEQUATABLEGENERIC)).Instantiate(nullableInst);
if (nullableInst[0].CanCastTo(iequatable))
{
TypeHandle resultTh = ((TypeHandle)CoreLibBinder::GetClass(CLASS__NULLABLE_COMPARER)).Instantiate(nullableInst);
return CORINFO_CLASS_HANDLE(resultTh.GetMethodTable());
}
}

// We need to special case the Enum comparers based on their underlying type to avoid boxing
if (elemTypeHnd.IsEnum())
{
Expand Down