mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Derived CRTP fixes
This commit is contained in:
parent
fda6c326c0
commit
a6e8436b2f
3 changed files with 45 additions and 1 deletions
|
@ -143,10 +143,11 @@ public:
|
||||||
|
|
||||||
BfPopulateType mPopulateType;
|
BfPopulateType mPopulateType;
|
||||||
BfTypeReference* mCurBaseTypeRef;
|
BfTypeReference* mCurBaseTypeRef;
|
||||||
|
BfTypeInstance* mCurBaseType;
|
||||||
BfTypeReference* mCurAttributeTypeRef;
|
BfTypeReference* mCurAttributeTypeRef;
|
||||||
BfFieldDef* mCurFieldDef;
|
BfFieldDef* mCurFieldDef;
|
||||||
BfTypeDef* mCurTypeDef;
|
BfTypeDef* mCurTypeDef;
|
||||||
BfTypeDef* mForceActiveTypeDef;
|
BfTypeDef* mForceActiveTypeDef;
|
||||||
ResolveKind mResolveKind;
|
ResolveKind mResolveKind;
|
||||||
BfAstNode* mCurVarInitializer;
|
BfAstNode* mCurVarInitializer;
|
||||||
int mArrayInitializerSize;
|
int mArrayInitializerSize;
|
||||||
|
@ -160,6 +161,7 @@ public:
|
||||||
|
|
||||||
mPopulateType = BfPopulateType_Identity;
|
mPopulateType = BfPopulateType_Identity;
|
||||||
mCurBaseTypeRef = NULL;
|
mCurBaseTypeRef = NULL;
|
||||||
|
mCurBaseType = NULL;
|
||||||
mCurFieldDef = NULL;
|
mCurFieldDef = NULL;
|
||||||
mCurAttributeTypeRef = NULL;
|
mCurAttributeTypeRef = NULL;
|
||||||
mCurTypeDef = NULL;
|
mCurTypeDef = NULL;
|
||||||
|
|
|
@ -3022,7 +3022,10 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
bool populateBase = !typeInstance->mTypeFailed;
|
bool populateBase = !typeInstance->mTypeFailed;
|
||||||
auto checkType = ResolveTypeRef(checkTypeRef, BfPopulateType_Declaration);
|
auto checkType = ResolveTypeRef(checkTypeRef, BfPopulateType_Declaration);
|
||||||
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
||||||
|
{
|
||||||
|
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
|
||||||
PopulateType(checkType, BfPopulateType_Data);
|
PopulateType(checkType, BfPopulateType_Data);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
||||||
{
|
{
|
||||||
|
@ -12793,6 +12796,19 @@ bool BfModule::TypeIsSubTypeOf(BfTypeInstance* srcType, BfTypeInstance* wantType
|
||||||
|
|
||||||
if (srcType->mDefineState < BfTypeDefineState_HasInterfaces)
|
if (srcType->mDefineState < BfTypeDefineState_HasInterfaces)
|
||||||
{
|
{
|
||||||
|
if (srcType->mDefineState == BfTypeDefineState_ResolvingBaseType)
|
||||||
|
{
|
||||||
|
auto typeState = mContext->mCurTypeState;
|
||||||
|
while (typeState != NULL)
|
||||||
|
{
|
||||||
|
if ((typeState->mTypeInstance == srcType) && (typeState->mCurBaseType != NULL))
|
||||||
|
{
|
||||||
|
return TypeIsSubTypeOf(typeState->mCurBaseType, wantType, checkAccessibility);
|
||||||
|
}
|
||||||
|
typeState = typeState->mPrevState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Type is incomplete. We don't do the IsIncomplete check here because of re-entry
|
// Type is incomplete. We don't do the IsIncomplete check here because of re-entry
|
||||||
// While handling 'var' resolution, we don't want to force a PopulateType reentry
|
// While handling 'var' resolution, we don't want to force a PopulateType reentry
|
||||||
// but we do have enough information for TypeIsSubTypeOf
|
// but we do have enough information for TypeIsSubTypeOf
|
||||||
|
|
26
IDEHelper/Tests/src/Classes.bf
Normal file
26
IDEHelper/Tests/src/Classes.bf
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
namespace Tests
|
||||||
|
{
|
||||||
|
class Classes
|
||||||
|
{
|
||||||
|
public abstract class Plugin<T> where T : Plugin<T>, new, class
|
||||||
|
{
|
||||||
|
public abstract void OnLoad();
|
||||||
|
public abstract void OnUnload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class ProgramPlugin<T> : Plugin<T> where T : ProgramPlugin<T>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ExamplePlugin : ProgramPlugin<ExamplePlugin>
|
||||||
|
{
|
||||||
|
public override void OnLoad()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnUnload()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue