mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Improved errors for invalid method specifiers in interfaces
This commit is contained in:
parent
ec92168669
commit
959ccebc26
1 changed files with 18 additions and 4 deletions
|
@ -21535,6 +21535,23 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
|
|
||||||
bool foundHiddenMethod = false;
|
bool foundHiddenMethod = false;
|
||||||
|
|
||||||
|
BfTokenNode* virtualToken = NULL;
|
||||||
|
auto propertyDeclaration = methodDef->GetPropertyDeclaration();
|
||||||
|
if (propertyDeclaration != NULL)
|
||||||
|
virtualToken = propertyDeclaration->mVirtualSpecifier;
|
||||||
|
else if (methodDeclaration != NULL)
|
||||||
|
virtualToken = methodDeclaration->mVirtualSpecifier;
|
||||||
|
|
||||||
|
if ((methodDef->mIsVirtual) && (methodDef->mIsStatic))
|
||||||
|
{
|
||||||
|
Fail("Static members cannot be marked as override, virtual, or abstract", virtualToken, true);
|
||||||
|
}
|
||||||
|
else if (methodDef->mIsVirtual)
|
||||||
|
{
|
||||||
|
if ((methodDef->mProtection == BfProtection_Private) && (virtualToken != NULL))
|
||||||
|
Fail("Virtual or abstract members cannot be private", virtualToken, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Don't compare specialized generic methods against normal methods
|
// Don't compare specialized generic methods against normal methods
|
||||||
if ((((mCurMethodInstance->mIsUnspecialized) || (mCurMethodInstance->mMethodDef->mGenericParams.size() == 0))) &&
|
if ((((mCurMethodInstance->mIsUnspecialized) || (mCurMethodInstance->mMethodDef->mGenericParams.size() == 0))) &&
|
||||||
(!methodDef->mIsLocalMethod))
|
(!methodDef->mIsLocalMethod))
|
||||||
|
@ -21858,16 +21875,13 @@ bool BfModule::SlotVirtualMethod(BfMethodInstance* methodInstance, BfAmbiguityCo
|
||||||
|
|
||||||
if ((methodDef->mIsVirtual) && (methodDef->mIsStatic))
|
if ((methodDef->mIsVirtual) && (methodDef->mIsStatic))
|
||||||
{
|
{
|
||||||
Fail("Static members cannot be marked as override, virtual, or abstract", virtualToken, true);
|
//Fail: Static members cannot be marked as override, virtual, or abstract
|
||||||
}
|
}
|
||||||
else if (methodDef->mIsVirtual)
|
else if (methodDef->mIsVirtual)
|
||||||
{
|
{
|
||||||
if (mCompiler->IsHotCompile())
|
if (mCompiler->IsHotCompile())
|
||||||
mContext->EnsureHotMangledVirtualMethodName(methodInstance);
|
mContext->EnsureHotMangledVirtualMethodName(methodInstance);
|
||||||
|
|
||||||
if ((methodDef->mProtection == BfProtection_Private) && (virtualToken != NULL))
|
|
||||||
Fail("Virtual or abstract members cannot be private", virtualToken, true);
|
|
||||||
|
|
||||||
BfTypeInstance* checkBase = typeInstance;
|
BfTypeInstance* checkBase = typeInstance;
|
||||||
// If we are in an extension, look in ourselves first
|
// If we are in an extension, look in ourselves first
|
||||||
if (methodDef->mDeclaringType->mTypeDeclaration == typeInstance->mTypeDef->mTypeDeclaration)
|
if (methodDef->mDeclaringType->mTypeDeclaration == typeInstance->mTypeDef->mTypeDeclaration)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue