blob: 5458c4b215f901b7aa993fe0b110357d8a7c743d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
using System;
using System.Collections;
using System.Collections.Generic;
public struct S : IEnumerable<int>
{
public S (int i)
{
}
public IEnumerator<int> GetEnumerator ()
{
return new Enumerator<int> ();
}
IEnumerator IEnumerable.GetEnumerator ()
{
throw new ApplicationException ();
}
}
public struct S2
{
public IEnumerator<int> GetEnumerator ()
{
return new Enumerator<int> ();
}
}
public struct Enumerator<T> : IEnumerator<T>
{
public T Current {
get {
throw new NotImplementedException ();
}
}
object IEnumerator.Current {
get {
throw new NotImplementedException ();
}
}
public bool MoveNext ()
{
return false;
}
public void Reset ()
{
throw new NotImplementedException ();
}
public void Dispose ()
{
MySystem.DisposeCounter++;
}
}
public class MySystem
{
public static int DisposeCounter;
public static int Main ()
{
S? s = new S ();
foreach (var a in s) {
}
if (DisposeCounter != 1)
return 1;
S2? s2 = new S2 ();
foreach (var a in s2) {
}
if (DisposeCounter != 2)
return 2;
return 0;
}
}
|