| Reporter |
Vladimir Reshetnikov (nikov)
|
|---|---|
| Created | May 1, 2012 3:48:46 AM |
| Updated | May 1, 2012 3:48:46 AM |
| Priority | Normal |
| Type | Bug |
| Fix versions | No Fix versions |
| State | Submitted |
| Assignee | Unassigned |
| Subsystem | No subsystem |
| Affected versions | No Affected versions |
| Fixed in build | No Fixed in build |
Module M
Sub Foo(x As Integer())
Dim y As New List(Of Func(Of Integer))
For Each e In x
y.Add(Function() e)
Next
End Sub
End Module
False 'Access to modified closure' warning.
Decompiled code:
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
[StandardModule]
internal sealed class M
{
public static void Foo(int[] x)
{
List<Func<int>> list1 = new List<Func<int>>();
int[] numArray = x;
int index = 0;
while (index < numArray.Length)
{
M._Closure\u0024__1 other = new M._Closure\u0024__1(other);
other.\u0024VB\u0024Local_e = numArray[index];
List<Func<int>> list2 = list1;
M._Closure\u0024__1 closure1 = other;
// ISSUE: virtual method pointer
IntPtr method = __vmethodptr(closure1, _Lambda\u0024__1);
Func<int> func = new Func<int>((object) closure1, method);
list2.Add(func);
checked { ++index; }
}
}
[CompilerGenerated]
internal class _Closure\u0024__1
{
public int \u0024VB\u0024Local_e;
[DebuggerNonUserCode]
public _Closure\u0024__1(M._Closure\u0024__1 other)
{
base.\u002Ector();
if (other == null)
return;
this.\u0024VB\u0024Local_e = other.\u0024VB\u0024Local_e;
}
[DebuggerNonUserCode]
public _Closure\u0024__1()
{
base.\u002Ector();
}
[CompilerGenerated]
[SpecialName]
public int _Lambda\u0024__1()
{
return this.\u0024VB\u0024Local_e;
}
}
}
Vladimir Reshetnikov (nikov)