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

test-16.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c59e917e191c39d521ce0560b5750e20aa461ee (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
using System;

namespace Mine {

	public class Blah {

		public static int operator + (Blah i, Blah j)
		{
			Console.WriteLine ("Base class binary + operator");
			return 2; 
		}

		public static implicit operator int (Blah i)
		{
			Console.WriteLine ("Blah->int");
			return 3;
		}

		public static implicit operator byte (Blah i)
		{
			Console.WriteLine ("Blah->byte");
			return 0;
		}
		
		public static implicit operator short (Blah i)
		{
			Console.WriteLine ("Blah->short");
			return 1;
		}
		
	}

	public class Foo : Blah {

		public static int Main ()
		{
			int number = new Foo () + new Foo () ;
			Console.WriteLine (number);

			Foo tmp = new Foo ();
			
			int k = tmp;

			Console.WriteLine ("Convert from Foo to float");
			float f = tmp;
			Console.WriteLine ("Converted");

			// The following will not work till we fix our UserCast::Emit
			// to convert the return value on the stack.
			if (f == 3)
				Console.WriteLine ("Best implicit conversion selected correctly.");

			Console.WriteLine ("F is {0}", f);

			if (number == 2 && k == 3)
				return 0;
			else
				return 1;
		}
	}
}