提交 1a4d7d6a 编写于 作者: C CyrusNajmabadi

Cleanup code.

上级 b3d74d70
......@@ -275,12 +275,12 @@ private static SyntaxNode GetNewMethodDeclaration(IMethodSymbol method, TArgumen
if (!TypeInfoMatchesType(argumentTypeInfo, parameter.Type))
{
if (parameter.IsParams && parameter.Type is IArrayTypeSymbol arrayType)
if (TypeInfoMatchesWithParamsExpansion(argumentTypeInfo, parameter))
{
if (TypeInfoMatchesType(argumentTypeInfo, arrayType.ElementType))
{
return null;
}
// The argument matched if we expanded out the params-parameter.
// As the params-parameter has to be last, there's nothing else to
// do here.
return null;
}
return argument;
......@@ -291,6 +291,19 @@ private static SyntaxNode GetNewMethodDeclaration(IMethodSymbol method, TArgumen
return null;
}
private bool TypeInfoMatchesWithParamsExpansion(TypeInfo argumentTypeInfo, IParameterSymbol parameter)
{
if (parameter.IsParams && parameter.Type is IArrayTypeSymbol arrayType)
{
if (TypeInfoMatchesType(argumentTypeInfo, arrayType.ElementType))
{
return true;
}
}
return false;
}
private bool TypeInfoMatchesType(TypeInfo argumentTypeInfo, ITypeSymbol type)
=> type.Equals(argumentTypeInfo.Type) || type.Equals(argumentTypeInfo.ConvertedType);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册