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

test-28.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 529f6ab123839164abdef07ab8978588dc1c196f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;
	
	int this [int a] {
		get {
			if (a == 0)
				return v1;
			else
				return v2;
		}

		set {
			if (a == 0)
				v1 = value;
			else
				v2 = value;
		}
	}

	public static int Main ()
	{
		X x = new X ();

		x [0] = 1;
		if (x.v1 != 1)
			return 1;

		if (x [0] != 1)
			return 2;

		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 ();
	}
}