blob: 32a9c19846e9cac7b39c1747e017a67e14644ce4 (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
using System;
public delegate long MyDelegate (int a);
public interface X
{
event EventHandler Foo;
event MyDelegate TestEvent;
}
public class Y : X
{
static int a = 0;
event EventHandler X.Foo {
add {
}
remove {
}
}
public event EventHandler Foo;
public event MyDelegate TestEvent;
public int Test ()
{
X x = this;
Foo += new EventHandler (callback1);
TestEvent += new MyDelegate (callback2);
x.Foo += new EventHandler (callback3);
if (a != 0)
return 1;
Foo (this, new EventArgs ());
if (a != 1)
return 2;
if (TestEvent (2) != 4)
return 3;
if (a != 2)
return 4;
return 0;
}
private static void callback1 (object sender, EventArgs e)
{
a = 1;
}
private static long callback2 (int b)
{
a = b;
return a * a;
}
private static void callback3 (object sender, EventArgs e)
{
a = 3;
}
}
public class Z : Y
{
public delegate int SomeEventHandler();
public static event SomeEventHandler BuildStarted;
static int a ()
{
return 1;
}
public static int Main ()
{
Z z = new Z ();
int result = z.Test ();
if (result != 0)
return result;
if (BuildStarted != null) {
BuildStarted();
}
BuildStarted = new SomeEventHandler (a);
if (BuildStarted () != 1)
return 50;
return 0;
}
}
//
// This class is just to test a bug in mcs; where we used to fail
// when accessing a static event, from an instance method.
//
public class Static {
public static event EventHandler Test;
public void Fire()
{
if ( Test != null )
Test (null, null);
}
}
|