提交 c5e64fe0 编写于 作者: G Gen Lu

Address review comments

上级 cfd402ce
......@@ -119,16 +119,11 @@ internal static IArgument CreateArgumentOperation(ArgumentKind kind, IParameterS
//TODO: https://github.com/dotnet/roslyn/issues/18722
// Right now, for erroneous code, we exposes all expression in place of arguments as IArgument with Parameter set to null,
// so user needs to check IsInvalid first before using anything we returned. Need to implement a new interface for invalid invocation instead.
if (n.HasErrors || optionalParametersMethod == null)
if (n.HasErrors || (object)optionalParametersMethod == null)
{
// optionalParametersMethod can be null if we are writing to a readonly indexer or reading from an writeonly indexer,
// in which case HasErrors property would be true, but we still want to treat this as invalid invocation.
ArrayBuilder<IArgument> argumentsWithErrors = ArrayBuilder<IArgument>.GetInstance(boundArguments.Length);
for (int a = 0; a < boundArguments.Length; ++a)
{
argumentsWithErrors.Add(CreateArgumentOperation(ArgumentKind.Explicit, null, boundArguments[a]));
}
return argumentsWithErrors.ToImmutableAndFree();
return boundArguments.SelectAsArray(arg => CreateArgumentOperation(ArgumentKind.Explicit, null, arg));
}
return LocalRewriter.MakeArgumentsInEvaluationOrder(
......
......@@ -391,7 +391,7 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
ArrayBuilder<LocalSymbol> temporariesBuilder = ArrayBuilder<LocalSymbol>.GetInstance();
rewrittenArguments = _factory.MakeTempsForDiscardArguments(rewrittenArguments, temporariesBuilder);
if (CanSkipRewriting(ref rewrittenArguments, methodOrIndexer, expanded, argsToParamsOpt, invokedAsExtensionMethod, out var isComReceiver))
if (CanSkipRewriting(rewrittenArguments, methodOrIndexer, expanded, argsToParamsOpt, invokedAsExtensionMethod, out var isComReceiver))
{
temps = temporariesBuilder.ToImmutableAndFree();
return rewrittenArguments;
......@@ -519,9 +519,7 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
ArrayBuilder<IArgument> argumentsInEvaluationBuilder = ArrayBuilder<IArgument>.GetInstance(parameters.Length);
bool canSkipRewriting = CanSkipRewriting(ref arguments, methodOrIndexer, expanded, argsToParamsOpt, invokedAsExtensionMethod, out var isComReceiver);
if (canSkipRewriting)
if (CanSkipRewriting(arguments, methodOrIndexer, expanded, argsToParamsOpt, invokedAsExtensionMethod, out var isComReceiver))
{
// In this case, the invocation is not in expanded form and there's no named argument provided.
// So we just return list of arguments as is.
......@@ -529,7 +527,7 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
{
argumentsInEvaluationBuilder.Add(BoundCall.CreateArgumentOperation(ArgumentKind.Explicit, parameters[i], arguments[i]));
}
return argumentsInEvaluationBuilder.ToImmutableAndFree(); ;
return argumentsInEvaluationBuilder.ToImmutableAndFree();
}
ArrayBuilder<ParameterSymbol> missingParametersBuilder = ArrayBuilder<ParameterSymbol>.GetInstance(parameters.Length);
......@@ -551,7 +549,7 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
// temporariesBuilder will be null when factory is null.
private static bool CanSkipRewriting(
ref ImmutableArray<BoundExpression> rewrittenArguments,
ImmutableArray<BoundExpression> rewrittenArguments,
Symbol methodOrIndexer,
bool expanded,
ImmutableArray<int> argsToParamsOpt,
......@@ -701,10 +699,7 @@ private static ImmutableArray<RefKind> GetRefKindsOrNull(ArrayBuilder<RefKind> r
// Set loop variable so the value for next iteration will be the index of the first non param-array argument after param-array argument(s).
a = firstNonParamArrayArgumentIndex - 1;
var paramArrayType = parameters[p].Type;
var arrayArgs = paramArray.ToImmutableAndFree();
argument = CreateParamArrayArgument(syntax, paramArrayType, arrayArgs, null, binder);
argument = CreateParamArrayArgument(syntax, parameter.Type, paramArray.ToImmutableAndFree(), null, binder);
}
argumentsBuilder.Add(BoundCall.CreateArgumentOperation(kind, parameter, argument));
......
......@@ -850,7 +850,7 @@ class P
}
[Fact]
public void CallerInfoAttributesInvokedInFieldInitilizer()
public void CallerInfoAttributesInvokedInFieldInitializer()
{
string source = @"
using System.Runtime.CompilerServices;
......
......@@ -302,7 +302,7 @@ protected void VerifyOperationTreeAndDiagnosticsForTest<TSyntaxNode>(CSharpCompi
CSharpParseOptions parseOptions = null,
MetadataReference[] additionalReferences = null,
Action<IOperation> AdditionalOperationTreeVerifier = null)
where TSyntaxNode : SyntaxNode
where TSyntaxNode : SyntaxNode
{
var ilReference = CreateMetadataReferenceFromIlSource(ilSource);
VerifyOperationTreeAndDiagnosticsForTest<TSyntaxNode>(testSrc, expectedOperationTree, expectedDiagnostics, compilationOptions, parseOptions, new[] { ilReference }, AdditionalOperationTreeVerifier);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册