@@ -180,8 +180,8 @@ private BoundStatement RewriteForEachEnumerator(
180180 }
181181
182182 // ((C)(x)).GetEnumerator(); OR (x).GetEnumerator(); OR async variants (which fill-in arguments for optional parameters)
183- BoundExpression enumeratorVarInitValue = SynthesizeCall ( getEnumeratorInfo , forEachSyntax , receiver ,
184- allowExtensionAndOptionalParameters : isAsync || getEnumeratorInfo . Method . IsExtensionMethod || getEnumeratorInfo . Method . GetIsNewExtensionMember ( ) , firstRewrittenArgument : firstRewrittenArgument ) ;
183+ BoundExpression enumeratorVarInitValue = MakeCall ( getEnumeratorInfo , forEachSyntax , receiver ,
184+ firstRewrittenArgument : firstRewrittenArgument ) ;
185185
186186 // E e = ((C)(x)).GetEnumerator();
187187 BoundStatement enumeratorVarDecl = MakeLocalDeclaration ( forEachSyntax , enumeratorVar , enumeratorVarInitValue ) ;
@@ -214,11 +214,10 @@ private BoundStatement RewriteForEachEnumerator(
214214 // }
215215
216216 var rewrittenBodyBlock = CreateBlockDeclaringIterationVariables ( iterationVariables , iterationVarDecl , rewrittenBody , forEachSyntax ) ;
217- BoundExpression rewrittenCondition = SynthesizeCall (
217+ BoundExpression rewrittenCondition = MakeCall (
218218 methodArgumentInfo : enumeratorInfo . MoveNextInfo ,
219219 syntax : forEachSyntax ,
220- receiver : boundEnumeratorVar ,
221- allowExtensionAndOptionalParameters : isAsync ,
220+ expression : boundEnumeratorVar ,
222221 firstRewrittenArgument : null ) ;
223222
224223 var disposalFinallyBlock = GetDisposalFinallyBlock ( forEachSyntax , enumeratorInfo , enumeratorType , boundEnumeratorVar , out var hasAsyncDisposal ) ;
@@ -369,7 +368,7 @@ private bool TryGetDisposeMethod(SyntaxNode forEachSyntax, ForEachEnumeratorInfo
369368 }
370369
371370 // ((IDisposable)e).Dispose() or e.Dispose() or await ((IAsyncDisposable)e).DisposeAsync() or await e.DisposeAsync()
372- disposeCall = MakeCallWithNoExplicitArgument ( disposeInfo , forEachSyntax , receiver , firstRewrittenArgument : null ) ;
371+ disposeCall = MakeCall ( disposeInfo , forEachSyntax , receiver , firstRewrittenArgument : null ) ;
373372
374373 BoundStatement disposeCallStatement ;
375374 var disposeAwaitableInfoOpt = enumeratorInfo . DisposeAwaitableInfo ;
@@ -535,19 +534,6 @@ private BoundExpression ConvertReceiverForInvocation(CSharpSyntaxNode syntax, Bo
535534 return receiver ;
536535 }
537536
538- private BoundExpression SynthesizeCall ( MethodArgumentInfo methodArgumentInfo , CSharpSyntaxNode syntax , BoundExpression ? receiver , bool allowExtensionAndOptionalParameters , BoundExpression ? firstRewrittenArgument )
539- {
540- if ( allowExtensionAndOptionalParameters )
541- {
542- // Generate a call with zero explicit arguments, but with implicit arguments for optional and params parameters.
543- return MakeCallWithNoExplicitArgument ( methodArgumentInfo , syntax , receiver , firstRewrittenArgument : firstRewrittenArgument ) ;
544- }
545-
546- // Generate a call with literally zero arguments
547- Debug . Assert ( methodArgumentInfo . Arguments . IsEmpty ) ;
548- return BoundCall . Synthesized ( syntax , receiver , initialBindingReceiverIsSubjectToCloning : ThreeState . Unknown , methodArgumentInfo . Method , arguments : ImmutableArray < BoundExpression > . Empty ) ;
549- }
550-
551537 /// <summary>
552538 /// Lower a foreach loop that will enumerate a collection via indexing.
553539 ///
0 commit comments