1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed multiple calls to base ctor in extension with bodyless ctor

This commit is contained in:
Brian Fiete 2020-12-29 09:23:29 -08:00
parent 78ae79b802
commit c91e8e0fb4
2 changed files with 36 additions and 2 deletions

View file

@ -16160,7 +16160,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
auto targetToken = BfNodeDynCast<BfTokenNode>(ctorInvocation->mTarget);
targetType = (targetToken->GetToken() == BfToken_This) ? mCurTypeInstance : mCurTypeInstance->mBaseType;
}
else if ((mCurTypeInstance->mBaseType != NULL) && (!mCurTypeInstance->IsUnspecializedType()))
else if ((mCurTypeInstance->mBaseType != NULL) && (!mCurTypeInstance->IsUnspecializedType()) && (methodDef->mMethodType != BfMethodType_CtorNoBody))
{
auto baseType = mCurTypeInstance->mBaseType;
if ((!mCurTypeInstance->IsTypedPrimitive()) &&

View file

@ -116,6 +116,36 @@ namespace Tests
public override void MethodA() { }
}
class ClassD
{
public int mD = MethodD0() ~ MethodD0();
public int MethodD0()
{
return mD + 1;
}
public void MethodD1()
{
}
}
class ClassE : ClassD
{
public int mE = MethodE0();
public int MethodE0()
{
return mE + 1;
}
}
extension ClassE
{
}
class TClassA<T> where T : IDisposable
{
public int32 mA = 10;
@ -192,6 +222,10 @@ namespace Tests
ClassC cc = scope .();
cc.MethodB();
ClassE ce = scope .();
Test.Assert(ce.mD == 1);
Test.Assert(ce.mE == 1);
}
[Test]