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

generic_type_definition_encoding.2.cs « tests « mono - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9ba17ce4b0a086d4434506179b7f2480f14c935f (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
using System.Collections.Generic;
using System;

class C<X,Y>
{
	class Q<A,B>
	{
		public  Type[] apply (C<X,Y> t)
		{
			return t.bar<A,B>();
		}
	}

	public  Type[] foo<A,B> ()
	{
		Q<A,B> q = new Q<A,B>();
		return q.apply(this);
	}

	public Type[] bar<A,B> ()
	{
		return new Type[] { typeof(X), typeof(Y), typeof(A), typeof(B) };
	}
}


class TypeofTest {
	public bool Bla() {
		Type t = typeof (Dictionary<,>);
		Type t2 = typeof (C<,>);
		return t.IsGenericTypeDefinition && t2.IsGenericTypeDefinition;
	}	
}

class TypeofTest2<X,Y> {
	public bool Bla() {
		Type t = typeof (Dictionary<,>);
		Type t2= typeof (C<,>);
		return t.IsGenericTypeDefinition && t2.IsGenericTypeDefinition;
	}	
}

class Driver {
	public static int Main () {
		C<int,string> c = new C<int,string>();
		Type[] types = c.foo<float,string> ();
		foreach (Type t in types)
			Console.WriteLine (t);
		if (types [0] != typeof (int))
			return 1;
		if (types [1] != typeof (string))
			return 2;
		if (types [2] != typeof (float))
			return 3;
		if (types [3] != typeof (string))
			return 4;

		if (!new TypeofTest().Bla())
			return 5;
		if (!new TypeofTest2<int, double>().Bla())
			return 6;

		return 0;
	}
}