Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2013-12-06 17:33:31 +0400
committerMarek Safar <marek.safar@gmail.com>2013-12-06 17:33:31 +0400
commitbb44c6895297b5475eb12eafe594556608c33633 (patch)
treeefae64b7738501db813f5ebc0e4e05c7fd0e0494 /mcs/tests/test-882.cs
parentc8d91bc505446f3d017f238250e6de608b603110 (diff)
[mcs] Add better type conversion to unary mutators. Fixes #16578
Diffstat (limited to 'mcs/tests/test-882.cs')
-rw-r--r--mcs/tests/test-882.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/mcs/tests/test-882.cs b/mcs/tests/test-882.cs
new file mode 100644
index 00000000000..67200e068d2
--- /dev/null
+++ b/mcs/tests/test-882.cs
@@ -0,0 +1,72 @@
+using System;
+
+public class MyUInt32
+{
+ public uint x;
+
+ public MyUInt32 (uint x)
+ {
+ this.x = x;
+ }
+
+ public static implicit operator uint (MyUInt32 v)
+ {
+ return v.x;
+ }
+
+ public static implicit operator long (MyUInt32 v)
+ {
+ throw new ApplicationException ();
+ }
+
+ public static implicit operator MyUInt32 (uint v)
+ {
+ return new MyUInt32 (v);
+ }
+
+ public static implicit operator MyUInt32 (long v)
+ {
+ throw new ApplicationException ();
+ }
+}
+
+class Test
+{
+ static MyUInt32 test1 (MyUInt32 x)
+ {
+ x = x + 1;
+ return x;
+ }
+
+ static MyUInt32 test2 (MyUInt32 x)
+ {
+ x++;
+ return x;
+ }
+
+ static MyUInt32 test3 (MyUInt32 x)
+ {
+ ++x;
+ return x;
+ }
+
+ public static int Main ()
+ {
+ var m = new MyUInt32 (2);
+ m = test1 (m);
+ if (m.x != 3)
+ return 1;
+
+ m = new MyUInt32 (2);
+ m = test2 (m);
+ if (m.x != 3)
+ return 2;
+
+ m = new MyUInt32 (3);
+ m = test3 (m);
+ if (m.x != 4)
+ return 3;
+
+ return 0;
+ }
+} \ No newline at end of file