[metadata] Fix leaks when handling a few attributes (#16675)
[mono-project.git] / mcs / tests / gtest-274.cs
blob30f4d3c5b4a53d02556a4f0205724850da3737d6
1 using System;
3 public struct Foo
5 public readonly long Value;
7 public Foo (long value)
9 this.Value = value;
12 public static implicit operator Foo (long value)
14 return new Foo (value);
18 public struct Bar
20 public readonly Foo Foo;
22 public Bar (Foo foo)
24 this.Foo = foo;
27 public static implicit operator Bar (Foo foo)
29 return new Bar (foo);
33 public struct Baz
35 public readonly Foo Foo;
37 public Baz (Foo foo)
39 this.Foo = foo;
42 public static explicit operator Baz (Foo foo)
44 return new Baz (foo);
48 struct S
50 public static implicit operator bool?(S arg)
52 throw new ApplicationException ("should not be called");
56 class X
58 public static int Main ()
60 int a = 3;
61 int? b = a;
62 int? b0 = null;
64 Foo? f1 = a;
65 Foo? f2 = b;
66 Foo? f3 = b0;
67 Foo f4 = (Foo) b;
69 Bar? b1 = f1;
70 Bar? b2 = f2;
71 Bar? b3 = f3;
72 Bar b4 = (Bar) f2;
74 Baz? z1 = (Baz?) f1;
75 Baz? z2 = (Baz?) f2;
76 Baz? z3 = (Baz?) f3;
77 Baz z4 = (Baz) f2;
79 S? s = null;
80 bool? g = s;
81 if (g != null)
82 return 1;
84 return 0;