Skip to content

Commit

Permalink
Misc.
Browse files Browse the repository at this point in the history
  • Loading branch information
cston committed Nov 15, 2023
1 parent 58b7841 commit 8871fda
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 33 deletions.
3 changes: 1 addition & 2 deletions src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4798,8 +4798,7 @@ BoundNode bindSpreadElement(SpreadElementSyntax syntax, BindingDiagnosticBag dia
lengthOrCount: lengthOrCount,
elementPlaceholder: null,
iteratorBody: null,
hasErrors: false)
{ WasCompilerGenerated = true };
hasErrors: false);
}
}
#nullable disable
Expand Down
1 change: 0 additions & 1 deletion src/Compilers/CSharp/Portable/CSharpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,6 @@ public static Conversion GetOutConversion(this ICompoundAssignmentOperation comp
/// </remarks>
public static Conversion GetSpreadItemConversion(this ISpreadOperation spread)
{
// PROTOTYPE: Test all branches.
if (spread == null)
{
throw new ArgumentNullException(nameof(spread));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,8 @@ private IOperation CreateBoundCollectionExpressionElement(BoundCollectionExpress
return element switch
{
BoundCollectionExpressionSpreadElement spreadElement => CreateBoundCollectionExpressionSpreadElement(spreadElement, getAddArgument(getIteratorBody(spreadElement))),
// PROTOTYPE: What about BoundDynamicCollectionElementInitializer? (See
// handling in LocalRewriter.VisitCollectionInitializerCollectionExpression.)
BoundCollectionElementInitializer initializer => Create(initializer.Arguments[0]),
BoundCollectionElementInitializer collectionInitializer => Create(collectionInitializer.Arguments[0]),
BoundDynamicCollectionElementInitializer dynamicInitializer => Create(dynamicInitializer.Arguments[0]),
_ => Create(element),
};
default:
Expand All @@ -1290,13 +1289,15 @@ private IOperation CreateBoundCollectionExpressionElement(BoundCollectionExpress

[return: NotNullIfNotNull("expr")] static BoundExpression? getAddArgument(BoundExpression? expr)
{
if (expr is BoundCall call)
return expr switch
{
// PROTOTYPE: This is not robust. What if there is no applicable Add() method and
// the expression is actually an invocation, and perhaps with no arguments?
return call.Arguments[0];
}
return expr;
BoundCall call => call.Arguments[0],
BoundDynamicInvocation dynamicInvocation => dynamicInvocation.Arguments[0],
// PROTOTYPE: We should look for specific BoundExpression kinds rather than just allowing any.
_ => expr,
};
}
}

Expand Down
Loading

0 comments on commit 8871fda

Please sign in to comment.