Skip to content

Commit

Permalink
Avoid crashing on unresolved dependencies (#70871)
Browse files Browse the repository at this point in the history
Fixes #70815.
  • Loading branch information
MichalStrehovsky authored Jun 17, 2022
1 parent 07b5741 commit c75659b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,11 @@ private void WalkMethod(EcmaMethod method)
&& _metadataReader.GetMemberReference((MemberReferenceHandle)accessedMethod).Parent.Kind == HandleKind.TypeSpecification))
{
var m = methodIL.GetObject(MetadataTokens.GetToken(accessedMethod), NotFoundBehavior.ReturnNull) as MethodDesc;
ProcessTypeReference(m.OwningType, typeContext, methodContext);
ProcessMethodCall(m, typeContext, methodContext);
if (m != null)
{
ProcessTypeReference(m.OwningType, typeContext, methodContext);
ProcessMethodCall(m, typeContext, methodContext);
}
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,21 @@ private void GetFlowDependenciesForInstantiation(ref DependencyList dependencies
var genericParameter = (GenericParameterDesc)typicalInstantiation[i];
if (FlowAnnotations.GetGenericParameterAnnotation(genericParameter) != default)
{
var deps = ILCompiler.Dataflow.ReflectionMethodBodyScanner.ProcessGenericArgumentDataFlow(factory, FlowAnnotations, Logger, genericParameter, instantiation[i], source);
if (deps.Count > 0)
try
{
if (dependencies == null)
dependencies = deps;
else
dependencies.AddRange(deps);
var deps = ILCompiler.Dataflow.ReflectionMethodBodyScanner.ProcessGenericArgumentDataFlow(factory, FlowAnnotations, Logger, genericParameter, instantiation[i], source);
if (deps.Count > 0)
{
if (dependencies == null)
dependencies = deps;
else
dependencies.AddRange(deps);
}
}
catch (TypeSystemException)
{
// Wasn't able to do dataflow because of missing references or something like that.
// This likely won't compile either, so we don't care about missing dependencies.
}
}
}
Expand Down

0 comments on commit c75659b

Please sign in to comment.