mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Fix for test methods on generic types
This commit is contained in:
parent
2bcfdcc06c
commit
e962a1a339
2 changed files with 36 additions and 10 deletions
|
@ -791,10 +791,24 @@ void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array<TestMethod>& test
|
|||
if (!isTest)
|
||||
return;
|
||||
|
||||
if (methodInstance->mIsUnspecialized)
|
||||
{
|
||||
if (!typeInstance->IsSpecializedType())
|
||||
{
|
||||
bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it's generic", bfModule->MethodToString(methodInstance).c_str()),
|
||||
methodInstance->mMethodDef->GetRefNode());
|
||||
}
|
||||
bfModule->mHadBuildError = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!methodInstance->mMethodDef->mIsStatic)
|
||||
{
|
||||
bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it is not static", bfModule->MethodToString(methodInstance).c_str()),
|
||||
methodInstance->mMethodDef->GetRefNode());
|
||||
if (!typeInstance->IsSpecializedType())
|
||||
{
|
||||
bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it's not static", bfModule->MethodToString(methodInstance).c_str()),
|
||||
methodInstance->mMethodDef->GetRefNode());
|
||||
}
|
||||
bfModule->mHadBuildError = true;
|
||||
return;
|
||||
}
|
||||
|
@ -804,8 +818,11 @@ void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array<TestMethod>& test
|
|||
if ((methodInstance->GetParamInitializer(0) == NULL) &&
|
||||
(methodInstance->GetParamKind(0) != BfParamKind_Params))
|
||||
{
|
||||
bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it contains parameters without defaults", bfModule->MethodToString(methodInstance).c_str()),
|
||||
methodInstance->mMethodDef->GetRefNode());
|
||||
if (!typeInstance->IsSpecializedType())
|
||||
{
|
||||
bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it contains parameters without defaults", bfModule->MethodToString(methodInstance).c_str()),
|
||||
methodInstance->mMethodDef->GetRefNode());
|
||||
}
|
||||
bfModule->mHadBuildError = true;
|
||||
return;
|
||||
}
|
||||
|
@ -831,12 +848,13 @@ void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array<TestMethod>& test
|
|||
if (typeInstance == NULL)
|
||||
continue;
|
||||
|
||||
if (typeInstance->IsUnspecializedType())
|
||||
continue;
|
||||
|
||||
for (auto& methodInstanceGroup : typeInstance->mMethodInstanceGroups)
|
||||
{
|
||||
if (methodInstanceGroup.mDefault != NULL)
|
||||
{
|
||||
_CheckMethod(typeInstance, methodInstanceGroup.mDefault);
|
||||
}
|
||||
if (methodInstanceGroup.mDefault != NULL)
|
||||
_CheckMethod(typeInstance, methodInstanceGroup.mDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9231,8 +9231,16 @@ String BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodNameFlags
|
|||
|
||||
if (type->IsUnspecializedType())
|
||||
type = ResolveGenericType(type, *methodGenericArgs);
|
||||
}
|
||||
methodName += TypeToString(type, typeNameFlags);
|
||||
}
|
||||
|
||||
if ((methodGenericArgs == NULL) && (mCurMethodInstance == NULL) && (mCurTypeInstance == NULL))
|
||||
{
|
||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, methodInst->GetOwner());
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, methodInst);
|
||||
methodName += TypeToString(type, typeNameFlags);
|
||||
}
|
||||
else
|
||||
methodName += TypeToString(type, typeNameFlags);
|
||||
}
|
||||
methodName += ">";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue