From: Aleksey Kliger Date: Thu, 21 Sep 2017 18:10:49 +0000 (-0400) Subject: [test] Add regression test for 58809 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=8540b4c9feb0f7b5deb333d6b7a236ca334df1d3 [test] Add regression test for 58809 Check that generic parameters's constraints properly affect the subclass and interface relationships even when the constraints relate several of the generic parameters themselves. --- diff --git a/mcs/class/corlib/Test/System/TypeTest.cs b/mcs/class/corlib/Test/System/TypeTest.cs index d03e4c21f2a..3fe3c3e61b4 100644 --- a/mcs/class/corlib/Test/System/TypeTest.cs +++ b/mcs/class/corlib/Test/System/TypeTest.cs @@ -3619,6 +3619,38 @@ namespace MonoTests.System public int field; } + [Test] + public void IsAssignableFromGenericArgumentsWithConstraints () + { + // Regression test for #58809 + + // Generic Parameters of a gtd should have their + // constraints respected even when those constraints + // are other generic parameters themselves. + + var ps = typeof (GenericWithParamConstraints<,,>).GetGenericArguments (); + + var a = ps[0]; + var b = ps[1]; + var c = ps[2]; + + // Foo + var fooOfC = typeof (Foo<>).MakeGenericType (c); + + // constraint B : Foo + Assert.IsTrue (fooOfC.IsAssignableFrom (b), "#1"); + + // constraint A : B + Assert.IsTrue (b.IsAssignableFrom (a), "#2"); + + // A : Foo since A : B and B : Foo + Assert.IsTrue (fooOfC.IsAssignableFrom (a), "#3"); + } + + class GenericWithParamConstraints where B : Foo where A : B + { + } + [Test] // Bug #612780 public void CannotMakeDerivedTypesFromTypedByRef () {