1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 15:24:10 +02:00

Fixed some struct* constraint checking

This commit is contained in:
Brian Fiete 2021-12-17 12:56:51 -05:00
parent ecdc22920a
commit 69a597574d
3 changed files with 34 additions and 8 deletions

View file

@ -23,6 +23,16 @@ namespace Tests
{
class Generics
{
struct StructA : IDisposable
{
int mA = 123;
public void Dispose()
{
}
}
class ClassA : IDisposable, LibA.IVal
{
int LibA.IVal.Val
@ -172,7 +182,7 @@ namespace Tests
delete val;
}
public static void Alloc2<T>() where T : new, delete, IDisposable, struct
public static void Alloc2<T>() where T : new, IDisposable, struct
{
alloctype(T) val = new T();
T* val2 = val;
@ -180,6 +190,14 @@ namespace Tests
delete val;
}
public static void Alloc3<T>() where T : new, IDisposable, struct*
{
T val2 = default;
if (val2 != null)
val2.Dispose();
delete val2;
}
public class ClassE
{
public static Self Instance = new ClassE() ~ delete _;
@ -311,6 +329,9 @@ namespace Tests
[Test]
public static void TestBasics()
{
Alloc2<StructA>();
Alloc3<StructA*>();
MethodD(scope => MethodC);
List<Entry> list = scope .();