Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how root provider resolve generic methods #749

Merged
merged 9 commits into from
Mar 1, 2021
14 changes: 7 additions & 7 deletions src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ static bool SignatureMatches(MethodDesc method, List<TypeDesc> parameter)
for (int i = 0; i < method.Signature.Length; i++)
{
if (method.Signature[i] != parameter[i])
{
return false;
}
}

return true;
}

Expand All @@ -176,26 +175,27 @@ static bool SignatureMatches(MethodDesc method, List<TypeDesc> parameter)
if (method.Name != methodName)
continue;

if (parameter.Count > 0 && !SignatureMatches(method, parameter))
continue;

if (instArgs.Count != method.Instantiation.Length)
throw new Exception($"Could not instantiate Method {method} specified by a Runtime Directive. Method takes {method.Instantiation.Length} generic argument(s) but {instArgs.Count} were provided.");
continue;

if (instArgs.Count > 0)
{
var methodInst = new Instantiation(instArgs.ToArray());
method = method.MakeInstantiatedMethod(methodInst);
}

if (parameter.Count > 0 && !SignatureMatches(method, parameter))
continue;

RootingHelpers.RootMethod(rootProvider, method, "RD.XML root");
rootedAnyMethod = true;
}

if (!rootedAnyMethod)
{
string parameterString = parameter.Count > 0 ? "(" + string.Join(", ", parameter) + ")" : null;
throw new Exception($"Could not find Method(s) {containingType}.{methodName}{parameterString} specified by a Runtime Directive.");
string instantiationString = instArgs.Count > 0 ? "<" + string.Join(", ", instArgs) + ">" : null;
throw new Exception($"Could not find Method(s) {containingType}.{methodName}{instantiationString}{parameterString} specified by a Runtime Directive.");
}
}
}
Expand Down