Skip to content

Commit

Permalink
Fix handling of not found exported types (#50845)
Browse files Browse the repository at this point in the history
This was missed in #50437.

Wonder if we should have just introduced a new overload of GetType that returns `object`. This "return resolution failure that we then need to not forget to check" looks like a potential bug farm.

```csharp
public MetadataType GetType(string nameSpace, string name, bool throwIfNotFound = true)
{
    /* the obvious implementation that calls the virtual method */
}

public abstract object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior)
```
  • Loading branch information
MichalStrehovsky authored Apr 8, 2021
1 parent a06eccb commit ae820d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,10 @@ private Object ResolveExportedType(ExportedTypeHandle handle)
var module = (ModuleDesc)implementation;
string nameSpace = _metadataReader.GetString(exportedType.Namespace);
string name = _metadataReader.GetString(exportedType.Name);
return module.GetType(nameSpace, name, NotFoundBehavior.ReturnResolutionFailure);
MetadataType resolvedType = module.GetType(nameSpace, name, NotFoundBehavior.ReturnResolutionFailure);
if (resolvedType == null)
return ModuleDesc.GetTypeResolutionFailure;
return resolvedType;
}
else
if (implementation is MetadataType)
Expand Down

0 comments on commit ae820d0

Please sign in to comment.