Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

36 lines
837 B
C#

//
// This test showed that there were cases where there was no
// shared "ScopeInfo", and that we could not root and keep a "topmost"
// variable in the compiler for a CaptureContext.
//
// This illustrates two roots of captured scopes, independent of
// each other
//
using System;
delegate void Do ();
class T {
static void doit (int v) {
Console.WriteLine (v);
}
public static void Main () {
Do[] arr = new Do [5];
for (int i = 0; i < 5; ++i) {
arr [i] = delegate {doit (i);};
}
for (int i = 0; i < 5; ++i) {
arr [i] ();
}
{
for (int j = 0; j < 5; ++j) {
arr [j] = delegate {doit (j);};
}
}
}
}