1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-23 18:18:00 +02:00

Fixed method selection by extern constraint specificity

This commit is contained in:
Brian Fiete 2021-01-05 13:51:31 -08:00
parent d0d89a552e
commit 56bcb6ecd1
2 changed files with 93 additions and 3 deletions

View file

@ -0,0 +1,50 @@
using System;
namespace Tests
{
class Generics2
{
struct TestFunc<T, Del>
{
private int mId;
private Del mComparer;
public static TestFunc<T, Del> Create(int id, Del comparer)
{
return .()
{
mId = id,
mComparer = comparer
};
}
public bool CheckDlg(T item)
{
return false;
}
public bool CheckDlg(T item) where Del : delegate bool(T)
{
return mComparer(item);
}
public bool CheckDlg(T item) where Del : delegate bool(int, T)
{
return mComparer(mId, item);
}
public bool CallCheck(T val)
{
return CheckDlg(val);
}
}
[Test]
public static void TestBasics()
{
let testF = TestFunc<String, delegate bool(String)>.Create(10, scope (s) => s == "Str");
Test.Assert(testF.CallCheck("Str"));
Test.Assert(!testF.CallCheck("Str2"));
}
}
}