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

test-136.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9e8216d8d3d2b0104b9e3364fb16f0441365022 (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
//
// Tests that explicit and normal implementations of methods are handled
// properly.  Before we used to have the normal method implementation
// "implement" the classes, so that it would go into an infinite loop.
// (bug #26334)
//
// Now explicit implementations are defined first.
//
using System;

public interface IDiagnostic
{
	void Stop();
} 
public interface IAutomobile
{
	void Stop();
}

public class MyCar: IAutomobile, IDiagnostic {
	public bool diag_stop, car_stop, auto_stop;
	
	void IDiagnostic.Stop() {
		diag_stop = true;
	}

	public void Stop() {
		car_stop = true;
		IAutomobile self = (IAutomobile)this; // cast this
		self.Stop(); // forwarding call
	}

	void IAutomobile.Stop()
	{
		auto_stop = true;
	}
}

class TestConflict {
	public static int Main ()
	{
		MyCar car1 = new MyCar();
		car1.Stop(); // calls the IAutomobile.Stop implementation
		
		IDiagnostic car2 = new MyCar();
		car2.Stop();
		
		IAutomobile car3 = new MyCar();
		car3.Stop();

		if (!car1.car_stop)
			return 1;

		if (car1.diag_stop)
			return 2;

		Console.WriteLine ("ok");
		return 0;
	}
}