blob: 30f4d3c5b4a53d02556a4f0205724850da3737d6 (
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
|
using System;
public struct Foo
{
public readonly long Value;
public Foo (long value)
{
this.Value = value;
}
public static implicit operator Foo (long value)
{
return new Foo (value);
}
}
public struct Bar
{
public readonly Foo Foo;
public Bar (Foo foo)
{
this.Foo = foo;
}
public static implicit operator Bar (Foo foo)
{
return new Bar (foo);
}
}
public struct Baz
{
public readonly Foo Foo;
public Baz (Foo foo)
{
this.Foo = foo;
}
public static explicit operator Baz (Foo foo)
{
return new Baz (foo);
}
}
struct S
{
public static implicit operator bool?(S arg)
{
throw new ApplicationException ("should not be called");
}
}
class X
{
public static int Main ()
{
int a = 3;
int? b = a;
int? b0 = null;
Foo? f1 = a;
Foo? f2 = b;
Foo? f3 = b0;
Foo f4 = (Foo) b;
Bar? b1 = f1;
Bar? b2 = f2;
Bar? b3 = f3;
Bar b4 = (Bar) f2;
Baz? z1 = (Baz?) f1;
Baz? z2 = (Baz?) f2;
Baz? z3 = (Baz?) f3;
Baz z4 = (Baz) f2;
S? s = null;
bool? g = s;
if (g != null)
return 1;
return 0;
}
}
|