mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Fixed some issues with types with extensions and emitted methods
This commit is contained in:
parent
d6af5b826f
commit
f7efa3466a
4 changed files with 28 additions and 9 deletions
|
@ -1176,6 +1176,9 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
|||
{
|
||||
auto emitTypeDef = typeInst->mTypeDef;
|
||||
typeInst->mTypeDef = emitTypeDef->mEmitParent;
|
||||
if (typeInst->mTypeDef->mIsPartial)
|
||||
typeInst->mTypeDef = mSystem->GetCombinedPartial(typeInst->mTypeDef);
|
||||
|
||||
BfLogSysM("Type %p queueing delete of typeDef %p, resetting typeDef to %p\n", typeInst, emitTypeDef, typeInst->mTypeDef);
|
||||
if (emitTypeDef->mDefState != BfTypeDef::DefState_Deleted)
|
||||
{
|
||||
|
|
|
@ -2352,11 +2352,6 @@ void BfModule::UpdateCEEmit(CeEmitContext* ceEmitContext, BfTypeInstance* typeIn
|
|||
defBuilder.mCurTypeDef = typeInstance->mTypeDef;
|
||||
defBuilder.mCurDeclaringTypeDef = typeInstance->mTypeDef;
|
||||
|
||||
if (typeInstance->mTypeDef->mIsCombinedPartial)
|
||||
{
|
||||
// Always define generated methods on the primary type declaration
|
||||
defBuilder.mCurDeclaringTypeDef = typeInstance->mTypeDef->mPartials[0]->GetLatest();
|
||||
}
|
||||
defBuilder.mPassInstance = mCompiler->mPassInstance;
|
||||
defBuilder.mIsComptime = true;
|
||||
defBuilder.DoVisitChild(typeDeclaration->mDefineNode);
|
||||
|
@ -9676,7 +9671,16 @@ BfTypeDef* BfModule::GetActiveTypeDef(BfTypeInstance* typeInstanceOverride, bool
|
|||
if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL) && (useMixinDecl))
|
||||
useTypeDef = mCurMethodState->mMixinState->mMixinMethodInstance->mMethodDef->mDeclaringType->GetDefinition();
|
||||
else if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mDeclaringType != NULL))
|
||||
useTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType->GetDefinition();
|
||||
{
|
||||
|
||||
auto declTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
||||
useTypeDef = declTypeDef->GetDefinition();
|
||||
if ((declTypeDef->IsEmitted()) && (useTypeDef->mIsCombinedPartial))
|
||||
{
|
||||
// Always consider methods to belong to the primary type declaration
|
||||
useTypeDef = useTypeDef->mPartials[0];
|
||||
}
|
||||
}
|
||||
else if (mContext->mCurTypeState != NULL)
|
||||
{
|
||||
if ((mContext->mCurTypeState->mCurFieldDef != NULL) && (mContext->mCurTypeState->mCurFieldDef->mDeclaringType != NULL))
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace Tests
|
|||
class ClassF
|
||||
{
|
||||
public int mA = 123;
|
||||
public append String mB = .(mA);
|
||||
public append String mB = .(1024);
|
||||
public int mC = 234;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace System
|
||||
{
|
||||
extension RefCounted<T>
|
||||
{
|
||||
public static RefCounted<T> Attach(RefCounted<T> val)
|
||||
{
|
||||
val.AddRef();
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace System
|
||||
{
|
||||
public extension Event<T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue