Skip to content

Commit

Permalink
Re-enable GetAsyncEnumerator optional parameter asserts (#72204)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz authored Feb 22, 2024
1 parent 18400db commit b0ebfe7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,7 @@ private EnumeratorResult SatisfiesIEnumerableInterfaces(ExpressionSyntax collect
extensionReceiverOpt: null,
expanded: false,
collectionExpr.Syntax,
diagnostics,
// C# 8 shipped allowing the CancellationToken of `IAsyncEnumerable.GetAsyncEnumerator` to be non-optional,
// filling in a default value in that case. https://github.com/dotnet/roslyn/issues/50182 tracks making
// this an error and breaking the scenario.
assertMissingParametersAreOptional: false);
diagnostics);

MethodSymbol currentPropertyGetter;
if (isAsync)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ private BoundStatement RewriteForEachEnumerator(

// ((C)(x)).GetEnumerator(); OR (x).GetEnumerator(); OR async variants (which fill-in arguments for optional parameters)
BoundExpression enumeratorVarInitValue = SynthesizeCall(getEnumeratorInfo, forEachSyntax, receiver,
allowExtensionAndOptionalParameters: isAsync || getEnumeratorInfo.Method.IsExtensionMethod,
// C# 8 shipped allowing the CancellationToken of `IAsyncEnumerable.GetAsyncEnumerator` to be non-optional.
// https://github.com/dotnet/roslyn/issues/50182 tracks making this an error and breaking the scenario.
assertParametersAreOptional: false);
allowExtensionAndOptionalParameters: isAsync || getEnumeratorInfo.Method.IsExtensionMethod);

// E e = ((C)(x)).GetEnumerator();
BoundStatement enumeratorVarDecl = MakeLocalDeclaration(forEachSyntax, enumeratorVar, enumeratorVarInitValue);
Expand Down

0 comments on commit b0ebfe7

Please sign in to comment.