blob: be7d7695a226769d66e653e436fe9df06406ad3a (
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
|
class Value {
public static explicit operator int (Value val)
{
return 1;
}
public static explicit operator MyObject (Value val)
{
return new MyObject (1);
}
public static explicit operator uint (Value val)
{
return 1;
}
}
class MyObject {
public MyObject (int i) {}
}
class Derived : MyObject {
public Derived (int i) : base (i) { }
Derived Blah ()
{
Value val = new Value ();
return (Derived) val;
}
}
class Test {
static int Main ()
{
Value v = new Value ();
v = null;
try {
// This will throw an exception.
// This test is more of a compile test, we need a real
// good test that does not require this lame catch.
Derived d = (Derived) v;
} catch {
}
return 0;
}
}
|