1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed 'new' methods where extension is in same project as orig decl

This commit is contained in:
Brian Fiete 2022-06-28 06:37:22 -07:00
parent f2b177693d
commit 4289d718d6

View file

@ -24420,8 +24420,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
methodInstance->mIsInnerOverride = true;
CheckOverridenMethod(methodInstance, checkMethodInstance);
}
else if ((methodDef->mDeclaringType->mProject != checkMethod->mDeclaringType->mProject) &&
(!checkMethod->mDeclaringType->IsExtension()))
else if (!checkMethod->mDeclaringType->IsExtension())
{
foundHiddenMethod = true;
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
@ -24430,6 +24429,8 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
{
silentlyAllow = true;
}
else if (checkMethod->GetMethodDeclaration() == NULL)
silentlyAllow = true;
else
extensionWarn = true;
}
@ -24448,9 +24449,15 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
auto refNode = methodDef->GetRefNode();
BfError* bfError;
if (extensionWarn)
{
if (methodDef->mDeclaringType->mProject != checkMethod->mDeclaringType->mProject)
bfError = Warn(BfWarning_CS0114_MethodHidesInherited,
StrFormat("This method hides a method in the root type definition. Use the 'new' keyword if the hiding was intentional. Note that this method is not callable from project '%s'.",
checkMethod->mDeclaringType->mProject->mName.c_str()), refNode);
else
bfError = Warn(BfWarning_CS0114_MethodHidesInherited,
"This method hides a method in the root type definition. Use the 'new' keyword if the hiding was intentional.", refNode);
}
else
{
bfError = Fail(StrFormat("Method '%s' already declared with the same parameter types", MethodToString(checkMethodInstance).c_str()), refNode, true);