1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Improved type constraint checks constrained by other generic params

This commit is contained in:
Brian Fiete 2022-06-11 07:56:43 -07:00
parent 10682e67af
commit 06ceaf617b
3 changed files with 55 additions and 26 deletions

View file

@ -165,6 +165,19 @@ namespace Tests
public static int GenClassMethodB(GenClass<int> a) { return a.test++; }
public static int GenClassMethodC<A>(A a) where A : GenClass<int> { return a.test += 1; }
public static TDerived AssertSubtype<TBase, TDerived>(TBase instance)
where TDerived : TBase
where TBase : class
{
if (instance == null)
Runtime.FatalError();
if (TDerived derived = instance as TDerived)
{
return derived;
}
Runtime.FatalError();
}
[Test]
public static void TestBasics()
{