Skip to content

Commit d7fe889

Browse files
committed
Improve type resolution of nested types
- Namespace doesn't get out of scope anymore. - Just comparing type name for the moment.
1 parent e48208b commit d7fe889

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/CLR/Core/TypeSystem.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,6 +4286,7 @@ bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, C
42864286
const CLR_RECORD_TYPEDEF *target = GetTypeDef(0);
42874287
int tblSize = tablesSize[TBL_TypeDef];
42884288
bool isNestedType = false;
4289+
std::string extractedNamespace;
42894290

42904291
// Check if typeName contains '/'
42914292
const char *slashPos = strchr(typeName, '/');
@@ -4296,10 +4297,19 @@ bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, C
42964297

42974298
// Extract the enclosed type name from the '/' backwards to the '.' before
42984299
const char *dotPos = strrchr(typeName, '.');
4299-
std::string enclosedTypeName(dotPos + 1, slashPos);
4300+
std::string enclosedTypeName;
43004301

4301-
// Extract the namespace from the beginning of the string to that '.'
4302-
std::string extractedNamespace(typeName, dotPos - typeName);
4302+
if (dotPos != nullptr)
4303+
{
4304+
enclosedTypeName.assign(dotPos + 1, slashPos);
4305+
// Extract the namespace from the beginning of the string to that '.'
4306+
extractedNamespace.assign(typeName, dotPos - typeName);
4307+
}
4308+
else
4309+
{
4310+
enclosedTypeName.assign(typeName, slashPos);
4311+
extractedNamespace.clear();
4312+
}
43034313

43044314
// Use the extracted values for further processing
43054315
typeName = extractedTypeName;
@@ -4319,7 +4329,9 @@ bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, C
43194329
const char *szNameSpace = GetString(target->nameSpace);
43204330
const char *szName = GetString(target->name);
43214331

4322-
if (!strcmp(szName, typeName) && !strcmp(szNameSpace, nameSpace))
4332+
// for nested types, there is no namespace encoded in the type
4333+
// looking at the type name only, does look a bit flaky but it will have to work for now
4334+
if (!strcmp(szName, typeName))
43234335
{
43244336
index.Set(assemblyIndex, i);
43254337
return true;

0 commit comments

Comments
 (0)