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

Added 'concrete' constraint

This commit is contained in:
Brian Fiete 2021-01-13 09:24:15 -08:00
parent 51ed3df320
commit e3f51e39ed
12 changed files with 90 additions and 72 deletions

View file

@ -226,9 +226,14 @@ namespace Tests
}
static int MethodE<T, T2>(T val) where T : IEnumerable<T2>
static T2 MethodE<T, T2>(T val) where T : concrete, IEnumerable<T2> where T2 : operator T2 + T2
{
return 0;
T2 total = default;
for (var v in val)
{
total += v;
}
return total;
}
static int MethodF<T>(IEnumerable<T> val)
@ -243,6 +248,7 @@ namespace Tests
List<Entry> list = scope .();
list.Sort();
List<float> floatList = scope .() {1, 2, 3};
ClassA ca = scope .();
ClassB cb = scope .();
@ -278,8 +284,15 @@ namespace Tests
Test.Assert(ClassE.Instance.CreateSystem<int>() == 999);
MethodE(list);
MethodF(list);
/*IEnumerable<float> ie = floatList;
Test.Assert(
[IgnoreErrors(true)]
{
Test.Assert(MethodE(ie) == 8);
true
} == false);*/
Test.Assert(MethodE(floatList) == 6);
Test.Assert(MethodF(floatList) == 0);
}
}

View file

@ -23,7 +23,7 @@ namespace Tests
}
}
concrete interface IFaceC
interface IFaceC
{
concrete IFaceA GetConcreteIA();
}