From eeed1bf41c71d9b03d7c62e4f00a8f295c8e842f Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 16 Jun 2022 11:17:01 -0700 Subject: [PATCH] Improved Find All References handling of virtual method overrides --- IDEHelper/Compiler/BfExprEvaluator.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index b98190db..752aa92d 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -9998,7 +9998,14 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp if ((identifierNode != NULL) && (methodDef->mIdx >= 0) && (!isIndirectMethodCall) && ((targetTypeInst == NULL) || (!targetTypeInst->IsDelegateOrFunction()))) { - mModule->mCompiler->mResolvePassData->HandleMethodReference(identifierNode, moduleMethodInstance.mMethodInstance->GetOwner()->mTypeDef, methodDef); + auto refMethodInstance = moduleMethodInstance.mMethodInstance; + if (refMethodInstance->mVirtualTableIdx != -1) + { + auto& virtualEntry = refMethodInstance->GetOwner()->mVirtualMethodTable[refMethodInstance->mVirtualTableIdx]; + refMethodInstance = virtualEntry.mDeclaringMethod; + } + + mModule->mCompiler->mResolvePassData->HandleMethodReference(identifierNode, refMethodInstance->GetOwner()->mTypeDef, refMethodInstance->mMethodDef); auto autoComplete = GetAutoComplete(); if ((autoComplete != NULL) && (autoComplete->IsAutocompleteNode(identifierNode))) { @@ -10026,8 +10033,8 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp if (autoComplete->mDefType == NULL) { - autoComplete->mDefMethod = methodDef; - autoComplete->mDefType = moduleMethodInstance.mMethodInstance->GetOwner()->mTypeDef; + autoComplete->mDefMethod = refMethodInstance->mMethodDef; + autoComplete->mDefType = refMethodInstance->GetOwner()->mTypeDef; } if (autoComplete->mResolveType == BfResolveType_GetResultString) @@ -10721,8 +10728,8 @@ void BfExprEvaluator::LookupQualifiedStaticField(BfAstNode* nameNode, BfIdentifi // Lookup left side as a type { BfType* type = mModule->ResolveTypeRef(nameLeft, NULL, BfPopulateType_Declaration, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_IgnoreLookupError | BfResolveTypeRefFlag_AllowGlobalContainer)); - if ((type != NULL) && (type->IsVar()) && (nameLeft->Equals("var"))) - type = NULL; + //if ((type != NULL) && (type->IsVar()) && (nameLeft->Equals("var"))) + //type = NULL; if (type != NULL) {