some minor code style changes
[mono.git] / mcs / tests / test-28.cs
index be95c09cd7cca60c187bc0c0e379927074974060..529f6ab123839164abdef07ab8978588dc1c196f 100644 (file)
@@ -1,3 +1,22 @@
+using System.Collections;
+abstract class A {
+        protected abstract int this [int a] { get; }
+
+       public int EmulateIndexer (int a)
+       {
+               return this [a];
+       }
+}
+
+class B : A {
+       protected override int this [int a] { get { return a;}  }
+
+       public int M ()
+       {
+               return this [0];
+       }
+       
+}
 class X {
        int v1, v2;
        
@@ -17,7 +36,7 @@ class X {
                }
        }
 
-       static int Main ()
+       public static int Main ()
        {
                X x = new X ();
 
@@ -28,7 +47,18 @@ class X {
                if (x [0] != 1)
                        return 2;
 
-               return 0;
-               
+               B bb = new B ();
+
+               if (bb.EmulateIndexer (10) != 10)
+                       return 3;
+
+               //
+               // This tests that we properly set the return type for the setter
+               // use pattern in the following indexer (see bug 36156)
+               Hashtable a = new Hashtable ();
+               int b = (int) (a [0] = 1);
+               if (b != 1)
+                       return 4;
+               return new B ().M ();
        }
 }