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>2017-11-17 15:05:24 +0300
committerMarek Safar <marek.safar@gmail.com>2017-11-20 14:22:48 +0300
commite5a8111a648c091d24d30a2a44873f378b193e71 (patch)
treec763df7f37f4e8c06df2b05f1045643110ddd860 /mcs/tests/test-ref-08.cs
parent1d7ec6a3d7f35302353633f0d3e94b4e3b1d2edf (diff)
[mcs] Better typed-ref deconstruction for indexers. Fixes #60680
Diffstat (limited to 'mcs/tests/test-ref-08.cs')
-rw-r--r--mcs/tests/test-ref-08.cs101
1 files changed, 101 insertions, 0 deletions
diff --git a/mcs/tests/test-ref-08.cs b/mcs/tests/test-ref-08.cs
new file mode 100644
index 00000000000..f4ff50f4c5c
--- /dev/null
+++ b/mcs/tests/test-ref-08.cs
@@ -0,0 +1,101 @@
+using System;
+
+namespace ClassLibrary1
+{
+ public class C
+ {
+
+ class B
+ {
+ int v;
+ public ref int this[int index]
+ {
+ get
+ {
+ return ref v;
+ }
+ }
+ }
+
+
+ class Gen<T> where T : struct
+ {
+ T v;
+ public ref T this[int index]
+ {
+ get
+ {
+ return ref v;
+ }
+ }
+ }
+
+ struct Val
+ {
+ }
+
+ class BB
+ {
+ Val v;
+ public ref Val this[int index]
+ {
+ get
+ {
+ return ref v;
+ }
+ }
+ }
+
+ void MM ()
+ {
+ var bbb = new BB();
+ Val v1 = bbb[0];
+ bbb[1] = v1;
+
+ ref Val v2 = ref bbb[2];
+ bbb[2] = v2;
+ }
+
+ static int[] a = new int[1];
+ public static void Main()
+ {
+ var bb = new B();
+ int b = 1;
+ bb[0] = b;
+ a[0] = Add2(ref b, 2);
+
+ var bbb = new BB();
+ bbb[0] = new Val();
+
+ var v = new Val();
+ bbb[1] = v;
+
+ var v2 = bbb[2];
+
+ bbb[3] = v2;
+
+
+ bbb[3] = bbb[2];
+
+
+
+ var ggg = new Gen<Val>();
+ ggg[0] = new Val();
+
+ var g = new Val();
+ ggg[1] = v;
+
+ var g2 = ggg[2];
+
+ ggg[3] = v2;
+
+
+ ggg[3] = ggg[2];
+ }
+
+ public static ref int Add2(ref int a, int b)
+ {
+ return ref a;
+ }
+ }
+} \ No newline at end of file