mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Removed assumption of class
on delegate constraint
This commit is contained in:
parent
e3ca70c153
commit
527935f371
2 changed files with 25 additions and 1 deletions
|
@ -515,7 +515,7 @@ bool BfModule::AreConstraintsSubset(BfGenericParamInstance* checkInner, BfGeneri
|
|||
outerFlags = (BfGenericParamFlags)(outerFlags | BfGenericParamFlag_Struct);
|
||||
else if (checkOuter->mTypeConstraint->IsStructOrStructPtr())
|
||||
outerFlags = (BfGenericParamFlags)(outerFlags | BfGenericParamFlag_StructPtr);
|
||||
else if (checkOuter->mTypeConstraint->IsObject())
|
||||
else if ((checkOuter->mTypeConstraint->IsObject()) && (!checkOuter->mTypeConstraint->IsDelegate()))
|
||||
outerFlags = (BfGenericParamFlags)(outerFlags | BfGenericParamFlag_Class);
|
||||
else if (checkOuter->mTypeConstraint->IsEnum())
|
||||
outerFlags = (BfGenericParamFlags)(outerFlags | BfGenericParamFlag_Enum | BfGenericParamFlag_Struct);
|
||||
|
|
|
@ -178,6 +178,23 @@ namespace Tests
|
|||
Runtime.FatalError();
|
||||
}
|
||||
|
||||
public static int TestOverload<TProc>(TProc proc)
|
||||
where TProc : class, delegate void()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int TestOverload<TProc>(TProc proc)
|
||||
where TProc : delegate void()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static int TestOverload2(function void() proc)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
@ -204,6 +221,13 @@ namespace Tests
|
|||
Test.Assert(gci.test == 2);
|
||||
Test.Assert(GenClassMethodC(gci) == 3);
|
||||
Test.Assert(gci.test == 3);
|
||||
|
||||
delegate void() dlg = scope () => {};
|
||||
function void() func = () => {};
|
||||
Test.Assert(TestOverload(dlg) == 1);
|
||||
Test.Assert(TestOverload(() => {}) == 2);
|
||||
Test.Assert(TestOverload(func) == 2);
|
||||
Test.Assert(TestOverload2(func) == 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue