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

Disallow funcs with explicit 'this' from binding to delegate constraint

This commit is contained in:
Brian Fiete 2022-06-15 13:48:09 -07:00
parent 527935f371
commit f8e57ee5ff

View file

@ -8336,9 +8336,16 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS
auto invokeMethod = GetRawMethodInstanceAtIdx(convCheckConstraint->ToTypeInstance(), 0, "Invoke"); auto invokeMethod = GetRawMethodInstanceAtIdx(convCheckConstraint->ToTypeInstance(), 0, "Invoke");
BfExprEvaluator exprEvaluator(this); if (checkMethodInstance->HasExplicitThis() != 0)
if (exprEvaluator.IsExactMethodMatch(checkMethodInstance, invokeMethod)) {
constraintMatched = true; // Don't allow functions with explicit 'this'
}
else
{
BfExprEvaluator exprEvaluator(this);
if (exprEvaluator.IsExactMethodMatch(checkMethodInstance, invokeMethod))
constraintMatched = true;
}
} }
else if (convCheckConstraint->IsInstanceOf(mCompiler->mDelegateTypeDef)) else if (convCheckConstraint->IsInstanceOf(mCompiler->mDelegateTypeDef))
constraintMatched = true; constraintMatched = true;