diff --git a/BeefLibs/corlib/src/Object.bf b/BeefLibs/corlib/src/Object.bf index a959af3d..2cd5833c 100644 --- a/BeefLibs/corlib/src/Object.bf +++ b/BeefLibs/corlib/src/Object.bf @@ -130,13 +130,13 @@ namespace System { return null; } +#endif [NoShow] public virtual Object DynamicCastToSignature(int32 sig) { return null; } -#endif int IHashable.GetHashCode() { diff --git a/IDEHelper/Compiler/BfDefBuilder.cpp b/IDEHelper/Compiler/BfDefBuilder.cpp index b433e1b7..3fe4a677 100644 --- a/IDEHelper/Compiler/BfDefBuilder.cpp +++ b/IDEHelper/Compiler/BfDefBuilder.cpp @@ -1355,9 +1355,9 @@ BfMethodDef* BfDefBuilder::AddDtor(BfTypeDef* typeDef) return methodDef; } -void BfDefBuilder::AddDynamicCastMethods(BfTypeDef* typeDef) +void BfDefBuilder::AddDynamicCastMethods(BfTypeDef* typeDef, bool needsDynamicCastMethods) { - // + if (needsDynamicCastMethods) { auto methodDef = new BfMethodDef(); methodDef->mIdx = (int)typeDef->mMethods.size(); @@ -1378,7 +1378,7 @@ void BfDefBuilder::AddDynamicCastMethods(BfTypeDef* typeDef) methodDef->mIsNoReflect = true; } - // + if (needsDynamicCastMethods) { auto methodDef = new BfMethodDef(); methodDef->mIdx = (int)typeDef->mMethods.size(); @@ -2392,10 +2392,10 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString) isAutocomplete = true; //TODO: Don't do this for the autocomplete pass - if ((needsDynamicCastMethod) && (mCurTypeDef->mTypeCode != BfTypeCode_Interface) && (mCurTypeDef->mTypeCode != BfTypeCode_Extension) && + if ((mCurTypeDef->mTypeCode != BfTypeCode_Interface) && (mCurTypeDef->mTypeCode != BfTypeCode_Extension) && (!mCurTypeDef->mIsStatic) && (!isAutocomplete) && (!isAlias) && (!mCurTypeDef->mIsOpaque)) { - AddDynamicCastMethods(mCurTypeDef); + AddDynamicCastMethods(mCurTypeDef, needsDynamicCastMethod); } bool isPayloadEnum = false; diff --git a/IDEHelper/Compiler/BfDefBuilder.h b/IDEHelper/Compiler/BfDefBuilder.h index 24566890..d683bfe1 100644 --- a/IDEHelper/Compiler/BfDefBuilder.h +++ b/IDEHelper/Compiler/BfDefBuilder.h @@ -52,7 +52,7 @@ public: static BfFieldDef* AddField(BfTypeDef* typeDef, BfTypeReference* typeRef, const StringImpl& name); static BfMethodDef* AddMethod(BfTypeDef* typeDef, BfMethodType methodType, BfProtection protection, bool isStatic, const StringImpl& name, bool addedAfterEmit = false); static BfMethodDef* AddDtor(BfTypeDef* typeDef); - static void AddDynamicCastMethods(BfTypeDef* typeDef); + static void AddDynamicCastMethods(BfTypeDef* typeDef, bool needsDynamicCastMethods); static void AddParam(BfMethodDef* methodDef, BfTypeReference* typeRef, const StringImpl& paramName); BfTypeDef* ComparePrevTypeDef(BfTypeDef* prevTypeDef, BfTypeDef* checkTypeDef); void FinishTypeDef(bool wantsToString); diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 10163973..acf0a926 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -9520,7 +9520,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty if (typeDef->mIsDelegate) { BfDefBuilder::AddMethod(typeDef, BfMethodType_Ctor, BfProtection_Public, false, ""); - BfDefBuilder::AddDynamicCastMethods(typeDef); + BfDefBuilder::AddDynamicCastMethods(typeDef, true); } delegateType->mContext = mContext; @@ -12907,7 +12907,7 @@ BfType* BfModule::ResolveTypeRef_Ref(BfTypeReference* typeRef, BfPopulateType po if (typeDef->mIsDelegate) { BfDefBuilder::AddMethod(typeDef, BfMethodType_Ctor, BfProtection_Public, false, ""); - BfDefBuilder::AddDynamicCastMethods(typeDef); + BfDefBuilder::AddDynamicCastMethods(typeDef, true); } delegateType->mContext = mContext;