diff --git a/IDE/mintest/minlib/src/System/Threading/Thread.bf b/IDE/mintest/minlib/src/System/Threading/Thread.bf index a45f5479..11c86de4 100644 --- a/IDE/mintest/minlib/src/System/Threading/Thread.bf +++ b/IDE/mintest/minlib/src/System/Threading/Thread.bf @@ -93,6 +93,11 @@ namespace System.Threading } } + private this() + { + + } + public this(ThreadStart start) { Debug.Assert(start != null); diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 8e4f3f4c..7f0d1197 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -5480,7 +5480,7 @@ BfTypedValue BfExprEvaluator::MatchConstructor(BfAstNode* targetSrc, BfMethodBou if (callCtorBodyOnly) { // We're calling the base class's ctor from a derived class - if (checkProt == BfProtection_Private) + if (checkProt <= BfProtection_Private) continue; } else diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index fab2285e..ebd48f5c 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -14408,52 +14408,62 @@ void BfModule::EmitCtorBody(bool& skipBody) (baseType->mTypeDef != mCompiler->mBfObjectTypeDef)) { // Try to find a ctor without any params first - bool foundBaseCtor = false; + BfMethodDef* matchedMethod = NULL; bool hadCtorWithAllDefaults = false; for (int pass = 0; pass < 2; pass++) { - for (auto checkMethodDef : baseType->mTypeDef->mMethods) + baseType->mTypeDef->PopulateMemberSets(); + BfMemberSetEntry* entry = NULL; + BfMethodDef* checkMethodDef = NULL; + baseType->mTypeDef->mMethodSet.TryGetWith(String("__BfCtor"), &entry); + if (entry != NULL) + checkMethodDef = (BfMethodDef*)entry->mMemberDef; + + while (checkMethodDef != NULL) { - bool allowPriv = checkMethodDef->mProtection != BfProtection_Private; + bool allowMethod = checkMethodDef->mProtection > BfProtection_Private; // Allow calling of the default base ctor if it is implicitly defined if ((checkMethodDef->mMethodDeclaration == NULL) && (pass == 1) && (!hadCtorWithAllDefaults)) - allowPriv = true; + allowMethod = true; - if ((checkMethodDef->mMethodType == BfMethodType_Ctor) && (!checkMethodDef->mIsStatic) && (allowPriv)) + if ((checkMethodDef->mMethodType == BfMethodType_Ctor) && (!checkMethodDef->mIsStatic) && (allowMethod)) { if (checkMethodDef->mParams.size() == 0) - { - foundBaseCtor = true; - if (HasCompiledOutput()) - { - SizedArray args; - auto ctorBodyMethodInstance = GetMethodInstance(mCurTypeInstance->mBaseType, checkMethodDef, BfTypeVector()); - if (!mCurTypeInstance->mBaseType->IsValuelessType()) - { - auto basePtr = mBfIRBuilder->CreateBitCast(mCurMethodState->mLocals[0]->mValue, mBfIRBuilder->MapTypeInstPtr(mCurTypeInstance->mBaseType)); - args.push_back(basePtr); - } - AddCallDependency(ctorBodyMethodInstance.mMethodInstance, true); - auto callInst = mBfIRBuilder->CreateCall(ctorBodyMethodInstance.mFunc, args); - auto callingConv = GetIRCallingConvention(ctorBodyMethodInstance.mMethodInstance); - if (callingConv != BfIRCallingConv_CDecl) - mBfIRBuilder->SetCallCallingConv(callInst, callingConv); -// if (!mCurTypeInstance->mBaseType->IsValuelessType()) -// mBfIRBuilder->SetCallCallingConv(callInst, BfIRCallingConv_ThisCall); - break; - } + { + matchedMethod = checkMethodDef; } else if ((checkMethodDef->mParams[0]->mParamDeclaration != NULL) && (checkMethodDef->mParams[0]->mParamDeclaration->mInitializer != NULL)) - hadCtorWithAllDefaults = true; + { + if (pass == 0) + hadCtorWithAllDefaults = true; + } } + + checkMethodDef = checkMethodDef->mNextWithSameName; } - if (foundBaseCtor) + if (matchedMethod != NULL) break; } - if (!foundBaseCtor) + if ((HasCompiledOutput()) && (matchedMethod != NULL)) + { + SizedArray args; + auto ctorBodyMethodInstance = GetMethodInstance(mCurTypeInstance->mBaseType, matchedMethod, BfTypeVector()); + if (!mCurTypeInstance->mBaseType->IsValuelessType()) + { + auto basePtr = mBfIRBuilder->CreateBitCast(mCurMethodState->mLocals[0]->mValue, mBfIRBuilder->MapTypeInstPtr(mCurTypeInstance->mBaseType)); + args.push_back(basePtr); + } + AddCallDependency(ctorBodyMethodInstance.mMethodInstance, true); + auto callInst = mBfIRBuilder->CreateCall(ctorBodyMethodInstance.mFunc, args); + auto callingConv = GetIRCallingConvention(ctorBodyMethodInstance.mMethodInstance); + if (callingConv != BfIRCallingConv_CDecl) + mBfIRBuilder->SetCallCallingConv(callInst, callingConv); + } + + if (matchedMethod == NULL) { targetType = mCurTypeInstance->mBaseType; if (ctorDeclaration != NULL)