2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-780.cs
blobd7ccc7eed768a1a013efe773fde73edb403da744
1 using System;
3 namespace MonoVirtuals
5 class X { }
6 class Y : X { }
8 class A
10 public virtual int f (X o)
12 System.Console.WriteLine ("In A for X");
13 return 5;
16 public virtual int f (Y o)
18 System.Console.WriteLine ("In A for Y");
19 return 10;
22 public virtual int this[X o]
24 get
26 System.Console.WriteLine ("In A for X");
27 return 5;
31 public virtual int this[Y o]
33 get
35 System.Console.WriteLine ("In A for Y");
36 return 10;
41 class B : A
43 public override int f (X o)
45 base.f (o);
46 throw new ApplicationException ("should not be called");
49 public override int this[X o]
51 get
53 base.f (o);
54 throw new ApplicationException ("should not be called");
59 class C : B
61 public override int f (X o)
63 System.Console.WriteLine ("In C for X");
64 return base.f (o);
67 public override int f (Y o)
69 System.Console.WriteLine ("In C for Y");
70 return base.f (o);
73 public override int this[X o]
75 get
77 System.Console.WriteLine ("In C for X");
78 return base.f (o);
82 public override int this[Y o]
84 get
86 System.Console.WriteLine ("In C for Y");
87 return base.f (o);
92 class MainClass
94 public static int Main ()
96 var o = new Y ();
97 var c = new C ();
98 if (c.f (o) != 10)
99 return 1;
101 if (c[o] != 10)
102 return 2;
104 return 0;