Skip to content

Commit

Permalink
Allow nested types inside of the <Module> type
Browse files Browse the repository at this point in the history
- This isn't disallowed by spec, although ilasm and ildasm cannot handle these cases
- Simply skip adding the type to the available class hash.

Backport of bugfix portion of PR #111435
Fixes #111164 in .NET 9
  • Loading branch information
davidwrighton committed Jan 16, 2025
1 parent e781fb7 commit f97890c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/coreclr/vm/clsload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3482,6 +3482,12 @@ VOID ClassLoader::AddAvailableClassHaveLock(
if (SUCCEEDED(pMDImport->GetNestedClassProps(classdef, &enclosing))) {
// nested type

if (enclosing == COR_GLOBAL_PARENT_TOKEN)
{
// Types nested in the <module> class can't be found by lookup.
return;
}

COUNT_T classEntryIndex = RidFromToken(enclosing) - 1;
_ASSERTE(RidFromToken(enclosing) < RidFromToken(classdef));
if (classEntries->GetCount() > classEntryIndex)
Expand Down

0 comments on commit f97890c

Please sign in to comment.