From 7093476126f6addf28b299b9254e758c0763c43d Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 22 Jan 2021 09:53:21 -0800 Subject: [PATCH] Fixed 'new' method specifier in extensions for generic types --- IDEHelper/Compiler/BfModule.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 507da9de..ea5d099b 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -22368,7 +22368,12 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool auto checkMethodInstance = typeInstance->mMethodInstanceGroups[checkMethod->mIdx].mDefault; if (checkMethodInstance == NULL) - continue; + { + if ((methodDef->mIsNew) && (methodDef->mDeclaringType->IsExtension()) && (!checkMethod->mDeclaringType->IsExtension())) + checkMethodInstance = GetRawMethodInstanceAtIdx(typeInstance, checkMethod->mIdx); + if (checkMethodInstance == NULL) + continue; + } if (((checkMethodInstance->mChainType == BfMethodChainType_None) || (checkMethodInstance->mChainType == BfMethodChainType_ChainHead)) && (checkMethodInstance->GetExplicitInterface() == methodInstance->GetExplicitInterface()) && @@ -22436,7 +22441,9 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic)) silentlyAllow = true; else if (methodDef->mIsNew) + { silentlyAllow = true; + } else extensionWarn = true; } @@ -22477,9 +22484,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool { auto baseType = typeInstance->mBaseType; while (baseType != NULL) - { - //for (int checkMethodIdx = 0; checkMethodIdx < (int) baseType->mTypeDef->mMethods.size(); checkMethodIdx++) - + { auto baseTypeDef = baseType->mTypeDef; baseTypeDef->PopulateMemberSets(); BfMethodDef* checkMethod = NULL; @@ -22533,8 +22538,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool baseType = baseType->mBaseType; } - - if ((methodDef->mIsNew) && (!foundHiddenMethod)) + if ((methodDef->mIsNew) && (!foundHiddenMethod) && (!mCurTypeInstance->IsSpecializedType())) { auto propertyDeclaration = methodDef->GetPropertyDeclaration(); auto tokenNode = (propertyDeclaration != NULL) ? propertyDeclaration->mNewSpecifier :