Skip to content

Commit

Permalink
Suppress 'hides inherited member' from base extension. Added MoreInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
bfiete committed Apr 27, 2024
1 parent ab31e5b commit 936dd65
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions IDEHelper/Compiler/BfModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25058,14 +25058,17 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
(checkMethod->mProtection != BfProtection_Private) &&
(CompareMethodSignatures(checkMethodInstance, mCurMethodInstance)))
{
if (!methodDef->mIsNew)
if ((!methodDef->mIsNew) && (!checkMethod->mDeclaringType->IsExtension()))
{
BfAstNode* refNode = methodInstance->mMethodDef->GetRefNode();
if (refNode != NULL)
{
BfError* bfError = Warn(BfWarning_CS0114_MethodHidesInherited, StrFormat("Method hides inherited member from '%s'. Use the 'new' keyword if the hiding was intentional.", TypeToString(baseType).c_str()), refNode); //CDH TODO should we mention override keyword in warning text?
if (bfError != NULL)
{
bfError->mIsPersistent = true;
mCompiler->mPassInstance->MoreInfo("See inherited method", checkMethod->GetRefNode());
}
}
}
foundHiddenMethod = true;
Expand Down Expand Up @@ -25992,7 +25995,11 @@ bool BfModule::SlotInterfaceMethod(BfMethodInstance* methodInstance)
}
else if (!methodDef->mIsNew)
{
Warn(BfWarning_CS0114_MethodHidesInherited, StrFormat("Method hides inherited member from '%s'. Use the 'new' keyword if hiding was intentional.", TypeToString(ifaceInst).c_str()), declaringNode);
auto error = Warn(BfWarning_CS0114_MethodHidesInherited, StrFormat("Method hides inherited member from '%s'. Use the 'new' keyword if hiding was intentional.", TypeToString(ifaceInst).c_str()), declaringNode);
if (error != NULL)
{
mCompiler->mPassInstance->MoreInfo("See inherited method", ifaceMethod->mMethodDef->GetRefNode());
}
}
}
}
Expand Down

0 comments on commit 936dd65

Please sign in to comment.