diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 6f283e9f..00900d7e 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -1920,10 +1920,10 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst goto NoMatch; } - if ((checkMethod->mParams.mSize > 0) && (methodInstance->GetParamKind(checkMethod->mParams.mSize - 1) == BfParamKind_Params)) + if ((methodInstance->mParams.mSize > 0) && (methodInstance->GetParamKind(methodInstance->mParams.mSize - 1) == BfParamKind_Params)) { // Handle `params int[C]` generic sized array params case - auto paramsType = methodInstance->GetParamType(checkMethod->mParams.mSize - 1); + auto paramsType = methodInstance->GetParamType(methodInstance->mParams.mSize - 1); if (paramsType->IsUnknownSizedArrayType()) { auto unknownSizedArray = (BfUnknownSizedArrayType*)paramsType; diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 80e18e3c..b500318c 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -8319,25 +8319,29 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS convCheckConstraint = ResolveGenericType(convCheckConstraint, NULL, methodGenericArgs, mCurTypeInstance); if (convCheckConstraint == NULL) return false; - if (((checkArgType->IsMethodRef()) || (checkArgType->IsFunction())) && (convCheckConstraint->IsDelegate())) + if ((checkArgType->IsMethodRef()) || (checkArgType->IsFunction())) { - BfMethodInstance* checkMethodInstance; - if (checkArgType->IsMethodRef()) + if (convCheckConstraint->IsDelegate()) { - auto methodRefType = (BfMethodRefType*)checkArgType; - checkMethodInstance = methodRefType->mMethodRef; - } - else - { - checkMethodInstance = GetRawMethodInstanceAtIdx(checkArgType->ToTypeInstance(), 0, "Invoke"); - } - - auto invokeMethod = GetRawMethodInstanceAtIdx(convCheckConstraint->ToTypeInstance(), 0, "Invoke"); + BfMethodInstance* checkMethodInstance; + if (checkArgType->IsMethodRef()) + { + auto methodRefType = (BfMethodRefType*)checkArgType; + checkMethodInstance = methodRefType->mMethodRef; + } + else + { + checkMethodInstance = GetRawMethodInstanceAtIdx(checkArgType->ToTypeInstance(), 0, "Invoke"); + } - BfExprEvaluator exprEvaluator(this); - if (exprEvaluator.IsExactMethodMatch(checkMethodInstance, invokeMethod)) + auto invokeMethod = GetRawMethodInstanceAtIdx(convCheckConstraint->ToTypeInstance(), 0, "Invoke"); + + BfExprEvaluator exprEvaluator(this); + if (exprEvaluator.IsExactMethodMatch(checkMethodInstance, invokeMethod)) + constraintMatched = true; + } + else if (convCheckConstraint->IsInstanceOf(mCompiler->mDelegateTypeDef)) constraintMatched = true; - } else if (CanCast(GetFakeTypedValue(checkArgType), convCheckConstraint)) { @@ -23466,7 +23470,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool { isValid = true; } - else if ((resolvedParamType->IsDelegate()) || (resolvedParamType->IsFunction())) + else if ((resolvedParamType->IsDelegate()) || (resolvedParamType->IsFunction()) || (resolvedParamType->IsMethodRef())) { hadDelegateParams = true; @@ -23487,7 +23491,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool } isValid = true; addParams = false; - } + } else if (resolvedParamType->IsGenericParam()) { auto genericParamInstance = GetGenericParamInstance((BfGenericParamType*)resolvedParamType); @@ -23745,7 +23749,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool { // If we have generic delegate params, it's possible we will fail constraints later if we specialize with an invalid type, but we can't allow that // to cause us to throw an assertion in the declaration here - if (!defaultMethodInstance->mHadGenericDelegateParams) + if ((!defaultMethodInstance->mHadGenericDelegateParams) && (!methodInstance->mHasFailed) && (!defaultMethodInstance->mHasFailed)) BF_ASSERT((isDone) && (isDefaultDone)); break; diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index f10f7037..60165bd2 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -568,6 +568,12 @@ BfMethodCustomAttributes::~BfMethodCustomAttributes() BfMethodInstance* BfMethodParam::GetDelegateParamInvoke() { + if (mResolvedType->IsMethodRef()) + { + auto methodRefType = (BfMethodRefType*)mResolvedType; + return methodRefType->mMethodRef; + } + BF_ASSERT(mResolvedType->IsDelegate() || mResolvedType->IsFunction()); auto bfModule = BfModule::GetModuleFor(mResolvedType); BfMethodInstance* invokeMethodInstance = bfModule->GetRawMethodInstanceAtIdx(mResolvedType->ToTypeInstance(), 0, "Invoke");