X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Ftests%2Ftest-136.cs;fp=mcs%2Ftests%2Ftest-136.cs;h=562cdbee956c3d32014f014772f0e07d2cf00db8;hb=144ff83b56a87464183f64a543d77c64496c16c5;hp=0000000000000000000000000000000000000000;hpb=33e2f0ce33fdc25878f0f9b4bd28bbd81bf8e080;p=mono.git diff --git a/mcs/tests/test-136.cs b/mcs/tests/test-136.cs new file mode 100755 index 00000000000..562cdbee956 --- /dev/null +++ b/mcs/tests/test-136.cs @@ -0,0 +1,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 { + 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; + } +}