Skip to content

Commit 08a6e06

Browse files
Fix TestGenericAddStaticField (#89145)
* Fix TestGenericAddStaticField * use the correct Method Table to gather fields
1 parent 068e528 commit 08a6e06

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

src/coreclr/vm/memberload.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,9 @@ void MemberLoader::GetDescFromMemberRef(ModuleBase * pModule,
365365

366366
if (pFD->IsStatic() && pMT->HasGenericsStaticsInfo())
367367
{
368-
//
369-
// <NICE> this is duplicated logic GetFieldDescByIndex </NICE>
370-
//
371-
INDEBUG(mdFieldDef token = pFD->GetMemberDef();)
372-
373-
DWORD pos = static_cast<DWORD>(pFD - (pMT->GetApproxFieldDescListRaw() + pMT->GetNumIntroducedInstanceFields()));
374-
_ASSERTE(pos >= 0 && pos < pMT->GetNumStaticFields());
375-
376-
pFD = pMT->GetGenericsStaticFieldDescs() + pos;
377-
_ASSERTE(pFD->GetMemberDef() == token);
378-
_ASSERTE(!pFD->IsSharedByGenericInstantiations());
379-
_ASSERTE(pFD->GetEnclosingMethodTable() == pMT);
368+
MethodTable* pFieldMT = pFD->GetApproxEnclosingMethodTable();
369+
DWORD index = pFieldMT->GetIndexForFieldDesc(pFD);
370+
pFD = pMT->GetFieldDescByIndex(index);
380371
}
381372

382373
*ppFD = pFD;

src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,6 @@ public static void TestReflectionAddNewMethod()
837837
});
838838
}
839839

840-
[ActiveIssue("https://github.com/dotnet/runtime/issues/87574", TestRuntimes.CoreCLR)]
841840
[ConditionalFact(typeof(ApplyUpdateUtil), nameof(ApplyUpdateUtil.IsSupported))]
842841
public static void TestGenericAddStaticField()
843842
{

0 commit comments

Comments
 (0)