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

gtest-054.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 03459441e59e57090c61e0861a91678c24317d34 (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
65
66
67
68
69
70
71
72
73
74
75
//
// Conversions involving type parameters (26.7.4).
// This is a compilation-only test since some of the explict
// conversions would trigger an InvalidCastException.
//

using System;

interface Foo
{
	void Hello ();
}

class A
{ }

class B : A, Foo
{
	public void Hello ()
	{ }

	public static implicit operator C (B b)
	{
		return new C ();
	}
}

class C
{
	public static explicit operator B (C c)
	{
		return new B ();
	}
}

class Test
{
	static void Simple<T> (T t)
	{
		object o = t;
		t = (T) o;
		Foo foo = (Foo) t;
		t = (T) foo;
	}

	static void Interface<T> (T t)
		where T : Foo
	{
		Foo foo = t;
	}

	static void Class<T> (T t)
		where T : B
	{
		B b = t;
		A a = t;
		Foo foo = t;
		t = (T) b;
		t = (T) a;
		t = (T) foo;
		C c = t;
		t = (T) c;
	}

	static void Array<T> (T[] t)
	{
		object o = t;
		Array a = t;
		t = (T []) o;
		t = (T []) a;
	}

	public static void Main ()
	{ }
}