Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Allow static self-referential struct type fields in interfaces #111984

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
9 changes: 7 additions & 2 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,11 @@ BOOL MethodTableBuilder::IsSelfReferencingStaticValueTypeField(mdToken dwByV
{
STANDARD_VM_CONTRACT;

if(this->IsInterface())
{
return TRUE;
}

if (dwByValueClassToken != this->GetCl())
{
return FALSE;
Expand Down Expand Up @@ -4042,7 +4047,7 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList,
// By-value class
BAD_FORMAT_NOTHROW_ASSERT(dwByValueClassToken != 0);

if (this->IsValueClass() && (pTokenModule == GetModule()))
if ((this->IsValueClass() || this->IsInterface()) && (pTokenModule == GetModule()))
{
if (TypeFromToken(dwByValueClassToken) == mdtTypeRef)
{
Expand Down Expand Up @@ -4101,7 +4106,7 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList,
BuildMethodTableThrowException(IDS_CLASSLOAD_VALUEINSTANCEFIELD, mdMethodDefNil);
}

if (!IsValueClass())
if (!IsValueClass() && !IsInterface())
{
BuildMethodTableThrowException(COR_E_BADIMAGEFORMAT, IDS_CLASSLOAD_MUST_BE_BYVAL, mdTokenNil);
}
Expand Down