Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,7 @@ void DacDbiInterfaceImpl::GetClassTypeInfo(TypeHandle typeH
DebuggerIPCE_ExpandedTypeData * pTypeInfo,
AppDomain * pAppDomain)
{
typeHandle = typeHandle.UpCastTypeIfNeeded();
Module * pModule = typeHandle.GetModule();

if (typeHandle.HasInstantiation()) // the type handle represents a generic instantiation
Expand Down Expand Up @@ -2402,9 +2403,10 @@ void DacDbiInterfaceImpl::TypeHandleToBasicTypeInfo(TypeHandle
case ELEMENT_TYPE_CLASS:
case ELEMENT_TYPE_VALUETYPE:
{
Module * pModule = typeHandle.GetModule();
typeHandle = typeHandle.UpCastTypeIfNeeded();

if (typeHandle.HasInstantiation()) // only set if instantiated
Module * pModule = typeHandle.GetModule();
if (typeHandle.HasInstantiation()) // only set if instantiated
{
pTypeInfo->vmTypeHandle.SetDacTargetPtr(typeHandle.AsTAddr());
}
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11657,6 +11657,7 @@ void Debugger::TypeHandleToBasicTypeInfo(AppDomain *pAppDomain, TypeHandle th, D
case ELEMENT_TYPE_CLASS:
case ELEMENT_TYPE_VALUETYPE:
{
th = th.UpCastTypeIfNeeded();
res->vmTypeHandle = th.HasInstantiation() ? WrapTypeHandle(th) : VMPTR_TypeHandle::NullPtr();
// only set if instantiated
res->metadataToken = th.GetCl();
Expand Down Expand Up @@ -11739,6 +11740,7 @@ void Debugger::TypeHandleToExpandedTypeInfo(AreValueTypesBoxed boxed,
case ELEMENT_TYPE_CLASS:
{
treatAllValuesAsBoxed:
th = th.UpCastTypeIfNeeded();
res->ClassTypeData.typeHandle = th.HasInstantiation() ? WrapTypeHandle(th) : VMPTR_TypeHandle::NullPtr(); // only set if instantiated
res->ClassTypeData.metadataToken = th.GetCl();
DebuggerModule * pModule = LookupOrCreateModule(th.GetModule());
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/typehandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ class TypeHandle
// And some types (like ByRef or generic type parameters) have no
// method table and this function returns NULL for them.
inline PTR_MethodTable GetMethodTable() const;
inline TypeHandle UpCastTypeIfNeeded() const;

// Returns the type which should be used for visibility checking.
inline MethodTable* GetMethodTableOfRootTypeParam() const;
Expand Down
18 changes: 18 additions & 0 deletions src/coreclr/vm/typehandle.inl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ inline PTR_MethodTable TypeHandle::GetMethodTable() const
return AsMethodTable();
}

// This method allows you to get the "upcasted" type handle. Currently we need this
// because continuation types for runtime-async methods are dynamically created subtypes of a
// parent continuation class that have no metadata of their own. This way, when we need to get
// the TypeHandle to retrieve metadata, we are able to get a reasonable approximation.
// If we need to handle more such types in the future we can add them here.
inline TypeHandle TypeHandle::UpCastTypeIfNeeded() const
{
LIMITED_METHOD_DAC_CONTRACT;

if (IsTypeDesc())
return *this;
if (AsMethodTable()->IsContinuation())
{
return TypeHandle(g_pContinuationClassIfSubTypeCreated);
}
return *this;
}

inline void TypeHandle::SetIsFullyLoaded()
{
LIMITED_METHOD_CONTRACT;
Expand Down
Loading