Skip to content

Commit 4994238

Browse files
Fix #3432: Do not include delegate construction use-sites in DetermineCaptureAndDeclarationScopes.
1 parent a264217 commit 4994238

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ void DetermineCaptureAndDeclarationScope(LocalFunctionInfo info, ILInstruction u
658658
switch (useSite)
659659
{
660660
case CallInstruction call:
661+
if (DelegateConstruction.MatchDelegateConstruction(useSite, out _, out _, out _))
662+
{
663+
// if this is a delegate construction, skip the use-site, because the capture scope
664+
// was already determined when analyzing "this".
665+
break;
666+
}
661667
int firstArgumentIndex = info.Definition.Method.IsStatic ? 0 : 1;
662668
for (int i = call.Arguments.Count - 1; i >= firstArgumentIndex; i--)
663669
{

0 commit comments

Comments
 (0)