From f8e57ee5ffca4dbc4a722351785f1d7f0abf3d3f Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 15 Jun 2022 13:48:09 -0700 Subject: [PATCH] Disallow funcs with explicit 'this' from binding to delegate constraint --- IDEHelper/Compiler/BfModule.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 46b13bf6..62670dfa 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -8336,9 +8336,16 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS auto invokeMethod = GetRawMethodInstanceAtIdx(convCheckConstraint->ToTypeInstance(), 0, "Invoke"); - BfExprEvaluator exprEvaluator(this); - if (exprEvaluator.IsExactMethodMatch(checkMethodInstance, invokeMethod)) - constraintMatched = true; + if (checkMethodInstance->HasExplicitThis() != 0) + { + // Don't allow functions with explicit 'this' + } + else + { + BfExprEvaluator exprEvaluator(this); + if (exprEvaluator.IsExactMethodMatch(checkMethodInstance, invokeMethod)) + constraintMatched = true; + } } else if (convCheckConstraint->IsInstanceOf(mCompiler->mDelegateTypeDef)) constraintMatched = true;