From b8d9e9845fa52de4ad9880bbef4b5282603cef8a Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 22 Mar 2024 17:27:17 -0400 Subject: [PATCH] Fixed new generic constraint check with foreign 'var' generic param --- IDEHelper/Compiler/BfModule.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index e8b9b0f9..67734570 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -8397,6 +8397,8 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS checkGenericParamFlags = checkGenericParamInst->mGenericParamFlags; if (checkGenericParamInst->mTypeConstraint != NULL) checkArgType = checkGenericParamInst->mTypeConstraint; + if (checkGenericParamInst->mGenericParamFlags & BfGenericParamFlag_Var) + checkArgType = GetPrimitiveType(BfTypeCode_Var); // if ((checkGenericParamFlags & (BfGenericParamFlag_Struct | BfGenericParamFlag_StructPtr)) != 0) // { @@ -8660,6 +8662,7 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS convCheckConstraint = ResolveGenericType(convCheckConstraint, NULL, methodGenericArgs, mCurTypeInstance); if (convCheckConstraint == NULL) return false; + if ((checkArgType->IsMethodRef()) || (checkArgType->IsFunction())) { if (convCheckConstraint->IsDelegate()) @@ -8693,7 +8696,7 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS else if ((checkArgType->IsFunction()) && (convCheckConstraint->IsInstanceOf(mCompiler->mFunctionTypeDef))) constraintMatched = true; } - else if ((checkArgType == convCheckConstraint) || (TypeIsSubTypeOf(checkArgType->ToTypeInstance(), convCheckConstraint->ToTypeInstance()))) + else if ((checkArgType == convCheckConstraint) || (checkArgType->IsVar()) || (TypeIsSubTypeOf(checkArgType->ToTypeInstance(), convCheckConstraint->ToTypeInstance()))) { constraintMatched = true; }